The UDFs are actually stored in the DB nodes (TPA), it's irrelevant whether you access the from a client in the Windows/Unix or mainframe.
UDFs can be written in C/C++ ... when you submit the code to TD through bteq, it internally transfers the source files to one of the PE nodes where a compiler is installed, where it's compiled and made into an object code which is distributed to all the DB nodes (TPA).
So irrespective of which platform you submitted your source code from, it would be compiled in the destination platform (TD's) and the object code would be generated in that platform.
Once the UDF is compiled in, you can access it from any client in any platform.
Some times you need to install third party UDFs etc which has only binaries and no source, in that case the binaries should be compatible with TD's platform.