summaryrefslogtreecommitdiffstats
path: root/src/mac/CFMglue.c
diff options
context:
space:
mode:
authorMiro Jurisic <meeroh@mit.edu>1998-08-10 16:33:41 +0000
committerMiro Jurisic <meeroh@mit.edu>1998-08-10 16:33:41 +0000
commit9cbea62f032946d56bf47e15c536a613a36deafa (patch)
treee142fd1c77291463d2288854863f7fcbade3f27c /src/mac/CFMglue.c
parentc5738ad068ecc90e9eb02cde258edec455ea45c2 (diff)
downloadkrb5-9cbea62f032946d56bf47e15c536a613a36deafa.tar.gz
krb5-9cbea62f032946d56bf47e15c536a613a36deafa.tar.xz
krb5-9cbea62f032946d56bf47e15c536a613a36deafa.zip
Added classic 68K glue
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10793 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/mac/CFMglue.c')
-rw-r--r--src/mac/CFMglue.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/src/mac/CFMglue.c b/src/mac/CFMglue.c
new file mode 100644
index 000000000..b2270885d
--- /dev/null
+++ b/src/mac/CFMglue.c
@@ -0,0 +1,104 @@
+#include <CodeFragments.h>
+
+// Private function prototypes
+
+static OSErr Find_Symbol(
+ Ptr* pSymAddr,
+ Str255 pSymName,
+ ProcInfoType pProcInfo);
+
+static pascal OSErr GetSystemArchitecture(OSType *archType);
+
+/* This code is directly from Technote 1077 */
+
+/* changed Library name to be hardcoded at the top of the file
+ instead in the middle of the code */
+
+// Private functions
+
+static pascal OSErr GetSystemArchitecture(OSType *archType)
+{
+ static long sSysArchitecture = 0; // static so we only Gestalt once.
+ OSErr tOSErr = noErr;
+
+ *archType = kAnyCFragArch; // assume wild architecture
+
+ // If we don't know the system architecture yet...
+ if (sSysArchitecture == 0)
+ // ...Ask Gestalt what kind of machine we are running on.
+ tOSErr = Gestalt(gestaltSysArchitecture, &sSysArchitecture);
+
+ if (tOSErr == noErr) // if no errors
+ {
+ if (sSysArchitecture == gestalt68k) // 68k?
+ *archType = kMotorola68KCFragArch;
+ else if (sSysArchitecture == gestaltPowerPC) // PPC?
+ *archType = kPowerPCCFragArch;
+ else
+ tOSErr = gestaltUnknownErr; // who knows what might be next?
+ }
+ return tOSErr;
+}
+
+static OSErr Find_Symbol(
+ Ptr* pSymAddr,
+ Str255 pSymName,
+ ProcInfoType pProcInfo)
+{
+ static CFragConnectionID sCID = 0;
+ static OSType sArchType = kAnyCFragArch;
+ static OSErr sOSErr = noErr;
+
+ Str255 errMessage;
+ Ptr mainAddr;
+ CFragSymbolClass symClass;
+ ISAType tISAType;
+
+ if (sArchType == kAnyCFragArch) // if architecture is undefined...
+ {
+ sCID = 0; // ...force (re)connect to library
+ sOSErr = GetSystemArchitecture(&sArchType); // determine architecture
+ if (sOSErr != noErr)
+ return sOSErr; // OOPS!
+ }
+
+ if (sArchType == kMotorola68KCFragArch) // ...for CFM68K
+ tISAType = kM68kISA | kCFM68kRTA;
+ else if (sArchType == kPowerPCCFragArch) // ...for PPC CFM
+ tISAType = kPowerPCISA | kPowerPCRTA;
+ else
+ sOSErr = gestaltUnknownErr; // who knows what might be next?
+
+ if (sCID == 0) // If we haven't connected to the library yet...
+ {
+ // NOTE: The library name is hard coded here.
+ // I try to isolate the glue code, one file per library.
+ // I have had developers pass in the Library name to allow
+ // plug-in type support. Additional code has to be added to
+ // each entry points glue routine to support multiple or
+ // switching connection IDs.
+ sOSErr = GetSharedLibrary(kLibraryName, sArchType, kLoadCFrag,
+ &sCID, &mainAddr, errMessage);
+ if (sOSErr != noErr)
+ return sOSErr; // OOPS!
+ }
+
+ // If we haven't looked up this symbol yet...
+ if ((Ptr) *pSymAddr == (Ptr) kUnresolvedCFragSymbolAddress)
+ {
+ // ...look it up now
+ sOSErr = FindSymbol(sCID,pSymName,pSymAddr,&symClass);
+ if (sOSErr != noErr) // in case of error...
+ // ...clear the procedure pointer
+ *(Ptr*) &pSymAddr = (Ptr) kUnresolvedCFragSymbolAddress;
+# if !GENERATINGCFM // if this is classic 68k code...
+ *pSymAddr = (Ptr)NewRoutineDescriptorTrap((ProcPtr) *pSymAddr,
+ pProcInfo, tISAType); // ...create a routine descriptor...
+# endif
+ }
+ return sOSErr;
+}
+
+/* --------------------------------- */
+/* Autogenerated section starts here */
+/* --------------------------------- */