+
+#elif defined(sparc_TARGET_ARCH)
+ /* Magic constant computed by inspecting the code length of
+ the following assembly language snippet
+ (offset and machine code prefixed):
+
+ <00>: 13 00 3f fb sethi %hi(0x00ffeffa), %o1 # load up wptr (1 of 2)
+ <04>: 11 37 ab 6f sethi %hi(0xdeadbeef), %o0 # load up hptr (1 of 2)
+ <08>: 81 c2 63 fa jmp %o1+%lo(0x00ffeffa) # jump to wptr (load 2 of 2)
+ <0c>: 90 12 22 ef or %o0, %lo(0xdeadbeef), %o0 # load up hptr (2 of 2)
+ # [in delay slot]
+ <10>: de ad be ef # Place the value of the StgStablePtr somewhere readable
+
+ ccall'ing on a SPARC leaves little to be performed by the caller.
+ The callee shifts the window on entry and restores it on exit.
+ Input paramters and results are passed via registers. (%o0 in the
+ code above contains the input paramter to wptr.) The return address
+ is stored in %o7/%i7. Since we don't shift the window in this code,
+ the return address is preserved and wptr will return to our caller.
+
+ */
+ sizeof_adjustor = 28*sizeof(char);
+
+ if ((adjustor = stgMallocBytes(sizeof_adjustor,"createAdjustor")) == NULL) {
+ return NULL;
+ }
+
+ adj_code = (unsigned char*)adjustor;
+
+ /* sethi %hi(wptr), %o1 */
+ *((unsigned long*)(adj_code+0x00)) = (unsigned long)0x13000000;
+ *((unsigned long*)(adj_code+0x00)) |= ((unsigned long)wptr) >> 10;
+
+ /* sethi %hi(hptr), %o0 */
+ *((unsigned long*)(adj_code+0x04)) = (unsigned long)0x11000000;
+ *((unsigned long*)(adj_code+0x04)) |= ((unsigned long)hptr) >> 10;
+
+ /* jmp %o1+%lo(wptr) */
+ *((unsigned long*)(adj_code+0x08)) = (unsigned long)0x81c26000;
+ *((unsigned long*)(adj_code+0x08)) |= ((unsigned long)wptr) & 0x000003ff;
+
+ /* or %o0, %lo(hptr), %o0 */
+ *((unsigned long*)(adj_code+0x0c)) = (unsigned long)0x90122000;
+ *((unsigned long*)(adj_code+0x0c)) |= ((unsigned long)hptr) & 0x000003ff;
+
+ *((StgStablePtr*)(adj_code+0x10)) = (StgStablePtr)hptr;
+#endif