oleaut: Reduce an ERR down to a WARN since a NULL interface pointer
[wine/multimedia.git] / dlls / kernel / selector.c
blobe157ca953e907701d4c6468e5a514058e2c7582c
1 /*
2 * Selector manipulation functions
4 * Copyright 1995 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <string.h>
26 #include "winerror.h"
27 #include "wine/winbase16.h"
28 #include "wine/server.h"
29 #include "wine/debug.h"
30 #include "kernel_private.h"
31 #include "toolhelp.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(selector);
35 #define LDT_SIZE 8192
37 /* get the number of selectors needed to cover up to the selector limit */
38 inline static WORD get_sel_count( WORD sel )
40 return (wine_ldt_copy.limit[sel >> __AHSHIFT] >> 16) + 1;
44 /***********************************************************************
45 * AllocSelectorArray (KERNEL.206)
47 WORD WINAPI AllocSelectorArray16( WORD count )
49 WORD i, sel = wine_ldt_alloc_entries( count );
51 if (sel)
53 LDT_ENTRY entry;
54 wine_ldt_set_base( &entry, 0 );
55 wine_ldt_set_limit( &entry, 1 ); /* avoid 0 base and limit */
56 wine_ldt_set_flags( &entry, WINE_LDT_FLAGS_DATA );
57 for (i = 0; i < count; i++) wine_ldt_set_entry( sel + (i << __AHSHIFT), &entry );
59 return sel;
63 /***********************************************************************
64 * AllocSelector (KERNEL.175)
66 WORD WINAPI AllocSelector16( WORD sel )
68 WORD newsel, count, i;
70 count = sel ? get_sel_count(sel) : 1;
71 newsel = wine_ldt_alloc_entries( count );
72 TRACE("(%04x): returning %04x\n", sel, newsel );
73 if (!newsel) return 0;
74 if (!sel) return newsel; /* nothing to copy */
75 for (i = 0; i < count; i++)
77 LDT_ENTRY entry;
78 wine_ldt_get_entry( sel + (i << __AHSHIFT), &entry );
79 wine_ldt_set_entry( newsel + (i << __AHSHIFT), &entry );
81 return newsel;
85 /***********************************************************************
86 * FreeSelector (KERNEL.176)
88 WORD WINAPI FreeSelector16( WORD sel )
90 LDT_ENTRY entry;
92 wine_ldt_get_entry( sel, &entry );
93 if (wine_ldt_is_empty( &entry )) return sel; /* error */
94 #ifdef __i386__
95 /* Check if we are freeing current %fs selector */
96 if (!((wine_get_fs() ^ sel) & ~3))
97 WARN("Freeing %%fs selector (%04x), not good.\n", wine_get_fs() );
98 #endif /* __i386__ */
99 wine_ldt_free_entries( sel, 1 );
100 return 0;
104 /***********************************************************************
105 * SELECTOR_SetEntries
107 * Set the LDT entries for an array of selectors.
109 static void SELECTOR_SetEntries( WORD sel, const void *base, DWORD size, unsigned char flags )
111 LDT_ENTRY entry;
112 WORD i, count;
114 wine_ldt_set_base( &entry, base );
115 wine_ldt_set_limit( &entry, size - 1 );
116 wine_ldt_set_flags( &entry, flags );
117 count = (size + 0xffff) / 0x10000;
118 for (i = 0; i < count; i++)
120 wine_ldt_set_entry( sel + (i << __AHSHIFT), &entry );
121 wine_ldt_set_base( &entry, (char*)wine_ldt_get_base(&entry) + 0x10000);
122 /* yep, Windows sets limit like that, not 64K sel units */
123 wine_ldt_set_limit( &entry, wine_ldt_get_limit(&entry) - 0x10000 );
128 /***********************************************************************
129 * SELECTOR_AllocBlock
131 * Allocate selectors for a block of linear memory.
133 WORD SELECTOR_AllocBlock( const void *base, DWORD size, unsigned char flags )
135 WORD sel, count;
137 if (!size) return 0;
138 count = (size + 0xffff) / 0x10000;
139 sel = wine_ldt_alloc_entries( count );
140 if (sel) SELECTOR_SetEntries( sel, base, size, flags );
141 return sel;
145 /***********************************************************************
146 * SELECTOR_FreeBlock
148 * Free a block of selectors.
150 void SELECTOR_FreeBlock( WORD sel )
152 WORD i, count = get_sel_count( sel );
154 TRACE("(%04x,%d)\n", sel, count );
155 for (i = 0; i < count; i++) FreeSelector16( sel + (i << __AHSHIFT) );
159 /***********************************************************************
160 * SELECTOR_ReallocBlock
162 * Change the size of a block of selectors.
164 WORD SELECTOR_ReallocBlock( WORD sel, const void *base, DWORD size )
166 LDT_ENTRY entry;
167 int oldcount, newcount;
169 if (!size) size = 1;
170 wine_ldt_get_entry( sel, &entry );
171 oldcount = (wine_ldt_get_limit(&entry) >> 16) + 1;
172 newcount = (size + 0xffff) >> 16;
174 sel = wine_ldt_realloc_entries( sel, oldcount, newcount );
175 if (sel) SELECTOR_SetEntries( sel, base, size, wine_ldt_get_flags(&entry) );
176 return sel;
180 /***********************************************************************
181 * PrestoChangoSelector (KERNEL.177)
183 WORD WINAPI PrestoChangoSelector16( WORD selSrc, WORD selDst )
185 LDT_ENTRY entry;
186 wine_ldt_get_entry( selSrc, &entry );
187 /* toggle the executable bit */
188 entry.HighWord.Bits.Type ^= (WINE_LDT_FLAGS_CODE ^ WINE_LDT_FLAGS_DATA);
189 wine_ldt_set_entry( selDst, &entry );
190 return selDst;
194 /***********************************************************************
195 * AllocCStoDSAlias (KERNEL.170)
196 * AllocAlias (KERNEL.172)
198 WORD WINAPI AllocCStoDSAlias16( WORD sel )
200 WORD newsel;
201 LDT_ENTRY entry;
203 newsel = wine_ldt_alloc_entries( 1 );
204 TRACE("(%04x): returning %04x\n",
205 sel, newsel );
206 if (!newsel) return 0;
207 wine_ldt_get_entry( sel, &entry );
208 entry.HighWord.Bits.Type = WINE_LDT_FLAGS_DATA;
209 wine_ldt_set_entry( newsel, &entry );
210 return newsel;
214 /***********************************************************************
215 * AllocDStoCSAlias (KERNEL.171)
217 WORD WINAPI AllocDStoCSAlias16( WORD sel )
219 WORD newsel;
220 LDT_ENTRY entry;
222 newsel = wine_ldt_alloc_entries( 1 );
223 TRACE("(%04x): returning %04x\n",
224 sel, newsel );
225 if (!newsel) return 0;
226 wine_ldt_get_entry( sel, &entry );
227 entry.HighWord.Bits.Type = WINE_LDT_FLAGS_CODE;
228 wine_ldt_set_entry( newsel, &entry );
229 return newsel;
233 /***********************************************************************
234 * LongPtrAdd (KERNEL.180)
236 void WINAPI LongPtrAdd16( DWORD ptr, DWORD add )
238 LDT_ENTRY entry;
239 wine_ldt_get_entry( SELECTOROF(ptr), &entry );
240 wine_ldt_set_base( &entry, (char *)wine_ldt_get_base(&entry) + add );
241 wine_ldt_set_entry( SELECTOROF(ptr), &entry );
245 /***********************************************************************
246 * GetSelectorBase (KERNEL.186)
248 DWORD WINAPI GetSelectorBase( WORD sel )
250 void *base = wine_ldt_copy.base[sel >> __AHSHIFT];
252 /* if base points into DOSMEM, assume we have to
253 * return pointer into physical lower 1MB */
255 return DOSMEM_MapLinearToDos( base );
259 /***********************************************************************
260 * SetSelectorBase (KERNEL.187)
262 WORD WINAPI SetSelectorBase( WORD sel, DWORD base )
264 LDT_ENTRY entry;
265 wine_ldt_get_entry( sel, &entry );
266 wine_ldt_set_base( &entry, DOSMEM_MapDosToLinear(base) );
267 wine_ldt_set_entry( sel, &entry );
268 return sel;
272 /***********************************************************************
273 * GetSelectorLimit (KERNEL.188)
275 DWORD WINAPI GetSelectorLimit16( WORD sel )
277 return wine_ldt_copy.limit[sel >> __AHSHIFT];
281 /***********************************************************************
282 * SetSelectorLimit (KERNEL.189)
284 WORD WINAPI SetSelectorLimit16( WORD sel, DWORD limit )
286 LDT_ENTRY entry;
287 wine_ldt_get_entry( sel, &entry );
288 wine_ldt_set_limit( &entry, limit );
289 wine_ldt_set_entry( sel, &entry );
290 return sel;
294 /***********************************************************************
295 * SelectorAccessRights (KERNEL.196)
297 WORD WINAPI SelectorAccessRights16( WORD sel, WORD op, WORD val )
299 LDT_ENTRY entry;
300 wine_ldt_get_entry( sel, &entry );
302 if (op == 0) /* get */
304 return entry.HighWord.Bytes.Flags1 | ((entry.HighWord.Bytes.Flags2 << 8) & 0xf0);
306 else /* set */
308 entry.HighWord.Bytes.Flags1 = LOBYTE(val) | 0xf0;
309 entry.HighWord.Bytes.Flags2 = (entry.HighWord.Bytes.Flags2 & 0x0f) | (HIBYTE(val) & 0xf0);
310 wine_ldt_set_entry( sel, &entry );
311 return 0;
316 /***********************************************************************
317 * IsBadCodePtr (KERNEL.336)
319 BOOL16 WINAPI IsBadCodePtr16( SEGPTR lpfn )
321 WORD sel;
322 LDT_ENTRY entry;
324 sel = SELECTOROF(lpfn);
325 if (!sel) return TRUE;
326 wine_ldt_get_entry( sel, &entry );
327 if (wine_ldt_is_empty( &entry )) return TRUE;
328 /* check for code segment, ignoring conforming, read-only and accessed bits */
329 if ((entry.HighWord.Bits.Type ^ WINE_LDT_FLAGS_CODE) & 0x18) return TRUE;
330 if (OFFSETOF(lpfn) > wine_ldt_get_limit(&entry)) return TRUE;
331 return FALSE;
335 /***********************************************************************
336 * IsBadStringPtr (KERNEL.337)
338 BOOL16 WINAPI IsBadStringPtr16( SEGPTR ptr, UINT16 size )
340 WORD sel;
341 LDT_ENTRY entry;
343 sel = SELECTOROF(ptr);
344 if (!sel) return TRUE;
345 wine_ldt_get_entry( sel, &entry );
346 if (wine_ldt_is_empty( &entry )) return TRUE;
347 /* check for data or readable code segment */
348 if (!(entry.HighWord.Bits.Type & 0x10)) return TRUE; /* system descriptor */
349 if ((entry.HighWord.Bits.Type & 0x0a) == 0x08) return TRUE; /* non-readable code segment */
350 if (strlen(MapSL(ptr)) < size) size = strlen(MapSL(ptr)) + 1;
351 if (size && (OFFSETOF(ptr) + size - 1 > wine_ldt_get_limit(&entry))) return TRUE;
352 return FALSE;
356 /***********************************************************************
357 * IsBadHugeReadPtr (KERNEL.346)
359 BOOL16 WINAPI IsBadHugeReadPtr16( SEGPTR ptr, DWORD size )
361 WORD sel;
362 LDT_ENTRY entry;
364 sel = SELECTOROF(ptr);
365 if (!sel) return TRUE;
366 wine_ldt_get_entry( sel, &entry );
367 if (wine_ldt_is_empty( &entry )) return TRUE;
368 /* check for data or readable code segment */
369 if (!(entry.HighWord.Bits.Type & 0x10)) return TRUE; /* system descriptor */
370 if ((entry.HighWord.Bits.Type & 0x0a) == 0x08) return TRUE; /* non-readable code segment */
371 if (size && (OFFSETOF(ptr) + size - 1 > wine_ldt_get_limit( &entry ))) return TRUE;
372 return FALSE;
376 /***********************************************************************
377 * IsBadHugeWritePtr (KERNEL.347)
379 BOOL16 WINAPI IsBadHugeWritePtr16( SEGPTR ptr, DWORD size )
381 WORD sel;
382 LDT_ENTRY entry;
384 sel = SELECTOROF(ptr);
385 if (!sel) return TRUE;
386 wine_ldt_get_entry( sel, &entry );
387 if (wine_ldt_is_empty( &entry )) return TRUE;
388 /* check for writeable data segment, ignoring expand-down and accessed flags */
389 if ((entry.HighWord.Bits.Type ^ WINE_LDT_FLAGS_DATA) & ~5) return TRUE;
390 if (size && (OFFSETOF(ptr) + size - 1 > wine_ldt_get_limit( &entry ))) return TRUE;
391 return FALSE;
394 /***********************************************************************
395 * IsBadReadPtr (KERNEL.334)
397 BOOL16 WINAPI IsBadReadPtr16( SEGPTR ptr, UINT16 size )
399 return IsBadHugeReadPtr16( ptr, size );
403 /***********************************************************************
404 * IsBadWritePtr (KERNEL.335)
406 BOOL16 WINAPI IsBadWritePtr16( SEGPTR ptr, UINT16 size )
408 return IsBadHugeWritePtr16( ptr, size );
412 /***********************************************************************
413 * IsBadFlatReadWritePtr (KERNEL.627)
415 BOOL16 WINAPI IsBadFlatReadWritePtr16( SEGPTR ptr, DWORD size, BOOL16 bWrite )
417 return bWrite? IsBadHugeWritePtr16( ptr, size )
418 : IsBadHugeReadPtr16( ptr, size );
422 /***********************************************************************
423 * MemoryRead (TOOLHELP.78)
425 DWORD WINAPI MemoryRead16( WORD sel, DWORD offset, void *buffer, DWORD count )
427 LDT_ENTRY entry;
428 DWORD limit;
430 wine_ldt_get_entry( sel, &entry );
431 if (wine_ldt_is_empty( &entry )) return 0;
432 limit = wine_ldt_get_limit( &entry );
433 if (offset > limit) return 0;
434 if (offset + count > limit + 1) count = limit + 1 - offset;
435 memcpy( buffer, (char *)wine_ldt_get_base(&entry) + offset, count );
436 return count;
440 /***********************************************************************
441 * MemoryWrite (TOOLHELP.79)
443 DWORD WINAPI MemoryWrite16( WORD sel, DWORD offset, void *buffer, DWORD count )
445 LDT_ENTRY entry;
446 DWORD limit;
448 wine_ldt_get_entry( sel, &entry );
449 if (wine_ldt_is_empty( &entry )) return 0;
450 limit = wine_ldt_get_limit( &entry );
451 if (offset > limit) return 0;
452 if (offset + count > limit) count = limit + 1 - offset;
453 memcpy( (char *)wine_ldt_get_base(&entry) + offset, buffer, count );
454 return count;
457 /************************************* Win95 pointer mapping functions *
461 struct mapls_entry
463 struct mapls_entry *next;
464 void *addr; /* linear address */
465 int count; /* ref count */
466 WORD sel; /* selector */
469 static struct mapls_entry *first_entry;
472 /***********************************************************************
473 * MapLS (KERNEL32.@)
474 * MapLS (KERNEL.358)
476 * Maps linear pointer to segmented.
478 SEGPTR WINAPI MapLS( LPCVOID ptr )
480 struct mapls_entry *entry, *free = NULL;
481 const void *base;
482 SEGPTR ret = 0;
484 if (!HIWORD(ptr)) return (SEGPTR)LOWORD(ptr);
486 base = (const char *)ptr - ((unsigned int)ptr & 0x7fff);
487 HeapLock( GetProcessHeap() );
488 for (entry = first_entry; entry; entry = entry->next)
490 if (entry->addr == base) break;
491 if (!entry->count) free = entry;
494 if (!entry)
496 if (!free) /* no free entry found, create a new one */
498 if (!(free = HeapAlloc( GetProcessHeap(), 0, sizeof(*free) ))) goto done;
499 if (!(free->sel = SELECTOR_AllocBlock( base, 0x10000, WINE_LDT_FLAGS_DATA )))
501 HeapFree( GetProcessHeap(), 0, free );
502 goto done;
504 free->count = 0;
505 free->next = first_entry;
506 first_entry = free;
508 SetSelectorBase( free->sel, (DWORD)base );
509 free->addr = (void*)base;
510 entry = free;
512 entry->count++;
513 ret = MAKESEGPTR( entry->sel, (const char *)ptr - (char *)entry->addr );
514 done:
515 HeapUnlock( GetProcessHeap() );
516 return ret;
519 /***********************************************************************
520 * UnMapLS (KERNEL32.@)
521 * UnMapLS (KERNEL.359)
523 * Free mapped selector.
525 void WINAPI UnMapLS( SEGPTR sptr )
527 struct mapls_entry *entry;
528 WORD sel = SELECTOROF(sptr);
530 if (sel)
532 HeapLock( GetProcessHeap() );
533 for (entry = first_entry; entry; entry = entry->next) if (entry->sel == sel) break;
534 if (entry && entry->count > 0) entry->count--;
535 HeapUnlock( GetProcessHeap() );
539 /***********************************************************************
540 * MapSL (KERNEL32.@)
541 * MapSL (KERNEL.357)
543 * Maps fixed segmented pointer to linear.
545 LPVOID WINAPI MapSL( SEGPTR sptr )
547 return (char *)wine_ldt_copy.base[SELECTOROF(sptr) >> __AHSHIFT] + OFFSETOF(sptr);
550 /***********************************************************************
551 * MapSLFix (KERNEL32.@)
553 * FIXME: MapSLFix and UnMapSLFixArray should probably prevent
554 * unexpected linear address change when GlobalCompact() shuffles
555 * moveable blocks.
558 LPVOID WINAPI MapSLFix( SEGPTR sptr )
560 return MapSL(sptr);
563 /***********************************************************************
564 * UnMapSLFixArray (KERNEL32.@)
566 * Must not change EAX, hence defined as asm function.
568 #ifdef __i386__
569 __ASM_GLOBAL_FUNC( UnMapSLFixArray, "ret $8" );
570 #endif
573 /***********************************************************************
574 * GetThreadSelectorEntry (KERNEL32.@)
576 BOOL WINAPI GetThreadSelectorEntry( HANDLE hthread, DWORD sel, LPLDT_ENTRY ldtent)
578 #ifdef __i386__
579 BOOL ret;
581 if (!(sel & 4)) /* GDT selector */
583 sel &= ~3; /* ignore RPL */
584 if (!sel) /* null selector */
586 memset( ldtent, 0, sizeof(*ldtent) );
587 return TRUE;
589 ldtent->BaseLow = 0;
590 ldtent->HighWord.Bits.BaseMid = 0;
591 ldtent->HighWord.Bits.BaseHi = 0;
592 ldtent->LimitLow = 0xffff;
593 ldtent->HighWord.Bits.LimitHi = 0xf;
594 ldtent->HighWord.Bits.Dpl = 3;
595 ldtent->HighWord.Bits.Sys = 0;
596 ldtent->HighWord.Bits.Pres = 1;
597 ldtent->HighWord.Bits.Granularity = 1;
598 ldtent->HighWord.Bits.Default_Big = 1;
599 ldtent->HighWord.Bits.Type = 0x12;
600 /* it has to be one of the system GDT selectors */
601 if (sel == (wine_get_ds() & ~3)) return TRUE;
602 if (sel == (wine_get_ss() & ~3)) return TRUE;
603 if (sel == (wine_get_cs() & ~3))
605 ldtent->HighWord.Bits.Type |= 8; /* code segment */
606 return TRUE;
608 SetLastError( ERROR_NOACCESS );
609 return FALSE;
612 SERVER_START_REQ( get_selector_entry )
614 req->handle = hthread;
615 req->entry = sel >> __AHSHIFT;
616 if ((ret = !wine_server_call_err( req )))
618 if (!(reply->flags & WINE_LDT_FLAGS_ALLOCATED))
620 SetLastError( ERROR_MR_MID_NOT_FOUND ); /* sic */
621 ret = FALSE;
623 else
625 wine_ldt_set_base( ldtent, (void *)reply->base );
626 wine_ldt_set_limit( ldtent, reply->limit );
627 wine_ldt_set_flags( ldtent, reply->flags );
631 SERVER_END_REQ;
632 return ret;
633 #else
634 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
635 return FALSE;
636 #endif
640 #ifdef __i386__
642 /***********************************************************************
643 * SMapLS (KERNEL32.@)
645 __ASM_GLOBAL_FUNC( SMapLS,
646 "xor %edx,%edx\n\t"
647 "testl $0xffff0000,%eax\n\t"
648 "jz 1f\n\t"
649 "pushl %eax\n\t"
650 "call " __ASM_NAME("MapLS") "\n\t"
651 "movl %eax,%edx\n"
652 "1:\tret" );
654 /***********************************************************************
655 * SUnMapLS (KERNEL32.@)
657 __ASM_GLOBAL_FUNC( SUnMapLS,
658 "pushl %eax\n\t" /* preserve eax */
659 "pushl %eax\n\t"
660 "call " __ASM_NAME("UnMapLS") "\n\t"
661 "popl %eax\n\t"
662 "ret" );
664 /***********************************************************************
665 * SMapLS_IP_EBP_8 (KERNEL32.@)
666 * SMapLS_IP_EBP_12 (KERNEL32.@)
667 * SMapLS_IP_EBP_16 (KERNEL32.@)
668 * SMapLS_IP_EBP_20 (KERNEL32.@)
669 * SMapLS_IP_EBP_24 (KERNEL32.@)
670 * SMapLS_IP_EBP_28 (KERNEL32.@)
671 * SMapLS_IP_EBP_32 (KERNEL32.@)
672 * SMapLS_IP_EBP_36 (KERNEL32.@)
673 * SMapLS_IP_EBP_40 (KERNEL32.@)
675 * These functions map linear pointers at [EBP+xxx] to segmented pointers
676 * and return them.
677 * Win95 uses some kind of alias structs, which it stores in [EBP+x] to
678 * unravel them at SUnMapLS. We just store the segmented pointer there.
680 #define DEFINE_SMapLS(n) \
681 __ASM_GLOBAL_FUNC( SMapLS_IP_EBP_ ## n, \
682 "movl " #n "(%ebp),%eax\n\t" \
683 "call " __ASM_NAME("SMapLS") "\n\t" \
684 "movl %edx," #n "(%ebp)\n\t" \
685 "ret" );
687 DEFINE_SMapLS(8);
688 DEFINE_SMapLS(12);
689 DEFINE_SMapLS(16);
690 DEFINE_SMapLS(20);
691 DEFINE_SMapLS(24);
692 DEFINE_SMapLS(28);
693 DEFINE_SMapLS(32);
694 DEFINE_SMapLS(36);
695 DEFINE_SMapLS(40);
698 /***********************************************************************
699 * SUnMapLS_IP_EBP_8 (KERNEL32.@)
700 * SUnMapLS_IP_EBP_12 (KERNEL32.@)
701 * SUnMapLS_IP_EBP_16 (KERNEL32.@)
702 * SUnMapLS_IP_EBP_20 (KERNEL32.@)
703 * SUnMapLS_IP_EBP_24 (KERNEL32.@)
704 * SUnMapLS_IP_EBP_28 (KERNEL32.@)
705 * SUnMapLS_IP_EBP_32 (KERNEL32.@)
706 * SUnMapLS_IP_EBP_36 (KERNEL32.@)
707 * SUnMapLS_IP_EBP_40 (KERNEL32.@)
710 #define DEFINE_SUnMapLS(n) \
711 __ASM_GLOBAL_FUNC( SUnMapLS_IP_EBP_ ## n, \
712 "pushl %eax\n\t" /* preserve eax */ \
713 "pushl " #n "(%ebp)\n\t" \
714 "call " __ASM_NAME("UnMapLS") "\n\t" \
715 "movl $0," #n "(%ebp)\n\t" \
716 "popl %eax\n\t" \
717 "ret" )
719 DEFINE_SUnMapLS(8);
720 DEFINE_SUnMapLS(12);
721 DEFINE_SUnMapLS(16);
722 DEFINE_SUnMapLS(20);
723 DEFINE_SUnMapLS(24);
724 DEFINE_SUnMapLS(28);
725 DEFINE_SUnMapLS(32);
726 DEFINE_SUnMapLS(36);
727 DEFINE_SUnMapLS(40);
729 #endif /* __i386__ */