Changeset 3884 for trunk


Ignore:
Timestamp:
Jun 28, 2014, 4:30:53 AM (11 years ago)
Author:
bird
Message:

More fixes.

Location:
trunk/libc
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/include/386/builtin.h

    r3866 r3884  
    570570
    571571
    572 #ifndef __WATCOMC__ /** @todo port me later. */
    573572/**
    574573 * Atomically compare and exchange a pointer.
     
    579578 * @param   pvCur   The current value. Only update if *pu32 equals this one.
    580579 */
     580#ifdef __WATCOMC__
     581unsigned __atomic_cmpxchgptr(void * volatile *ppv, void *pvNew,  void *pvOld);
     582# pragma aux __atomic_cmpxchgptr = \
     583    "lock cmpxchg [edx], ecx" \
     584    "setz  al" \
     585    "movzx eax, al" \
     586    parm [edx] [ecx] [eax]  value [eax]
     587#else
    581588static inline unsigned __atomic_cmpxchgptr(void * volatile *ppv, void *pvNew,  void *pvOld)
    582589{
     590# ifdef _MSC_VER
     591    uint32_t uOrg = _InterlockedCompareExchange((long volatile *)ppv, (uintptr_t)pvNew, (uintptr_t)pvOld)
     592    return uOrg == (uintptr_t)pvOld;
     593# else
    583594    __asm__ __volatile__("lock; cmpxchgl %2, %1\n\t"
    584595                         "setz  %%al\n\t"
     
    589600                           "0" (pvOld));
    590601    return (uintptr_t)pvOld;
    591 }
     602# endif
     603}
     604#endif
    592605
    593606
     
    598611 * @param   iBit        The bit to be set.
    599612 */
     613#ifdef __WATCOMC__
     614void __bit_set(void volatile *pvBitmap, uint32_t iBit);
     615# pragma aux __bit_set = "bts [eax], edx" parm [eax] [edx]
     616#else
    600617static inline void __bit_set(void volatile *pvBitmap, uint32_t iBit)
    601618{
     619# ifdef _MSC_VER
     620    _bittestandset((long *)pvBitmap, iBit);
     621# else
    602622    __asm__ __volatile__("btsl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory");
    603 }
     623# endif
     624}
     625#endif
    604626
    605627/**
     
    609631 * @param   iBit        The bit to be cleared.
    610632 */
     633#ifdef __WATCOMC__
     634void __bit_clear(void volatile *pvBitmap, uint32_t iBit);
     635# pragma aux __bit_clear = "btr [eax], edx" parm [eax] [edx]
     636#else
    611637static inline void __bit_clear(void volatile *pvBitmap, uint32_t iBit)
    612638{
     639# ifdef _MSC_VER
     640    _bittestandreset((long *)pvBitmap, iBit);
     641# else
    613642    __asm__ __volatile__("btrl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory");
    614 }
     643# endif
     644}
     645#endif
    615646
    616647/**
     
    620651 * @param   iBit        The bit to be cleared.
    621652 */
     653#ifdef __WATCOMC__
     654void __bit_toggle(void volatile *pvBitmap, uint32_t iBit);
     655# pragma aux __bit_toggle = "btc [eax], edx" parm [eax] [edx]
     656#else
    622657static inline void __bit_toggle(void volatile *pvBitmap, uint32_t iBit)
    623658{
     659# ifdef _MSC_VER
     660    _bittestandcomplement((long *)pvBitmap, iBit);
     661# else
    624662    __asm__ __volatile__("btcl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory");
    625 }
     663# endif
     664}
     665#endif
    626666
    627667/**
     
    632672 * @param   iBit        The bit to be tested.
    633673 */
     674#ifdef __WATCOMC__
     675_Bool __bit_test(void volatile *pvBitmap, uint32_t iBit);
     676# pragma aux __bit_toggle = \
     677    "bt  [edx], eax" \
     678    "sbb eax, eax" \
     679    "neg eax" \
     680    parm [edx] [eax] value [al]
     681#else
    634682static inline _Bool __bit_test(void volatile *pvBitmap, uint32_t iBit)
    635683{
     684# ifdef _MSC_VER
     685    return _bittest((long *)pvBitmap, iBit);
     686# else
    636687    union { _Bool f; uint32_t u32; } u;
    637688
    638689    __asm__ __volatile__("btl %2, %1\n\t"
    639                          "sbbl %0, %0"
     690                         "sbbl %0, %0\n\t"
     691                         "neg %0\n\t"
    640692                         : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap)
    641693                         : "Ir" (iBit));
    642694    return u.f;
    643 }
     695# endif
     696}
     697#endif
     698
    644699
    645700/**
     
    650705 * @param   iBit        The bit to be tested and set.
    651706 */
     707#ifdef __WATCOMC__
     708_Bool __bit_test_and_set(void volatile *pvBitmap, uint32_t iBit);
     709# pragma aux __bit_test_and_set = \
     710    "bts [edx], eax" \
     711    "sbb eax, eax" \
     712    "neg eax" \
     713    parm [edx] [eax] value [al]
     714#else
    652715static inline _Bool __bit_test_and_set(void volatile *pvBitmap, uint32_t iBit)
    653716{
     717# ifdef _MSC_VER
     718    return _bittestandset((long *)pvBitmap, iBit);
     719# else
    654720    union { _Bool f; uint32_t u32; } u;
    655721
    656722    __asm__ __volatile__("btsl %2, %1\n\t"
    657                          "sbbl %0, %0"
     723                         "sbbl %0, %0\n\t"
     724                         "neg %0\n\t"
    658725                         : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap)
    659726                         : "Ir" (iBit));
    660727    return u.f;
    661 }
     728# endif
     729}
     730#endif
    662731
    663732/**
     
    668737 * @param   iBit        The bit to be tested and cleared.
    669738 */
     739#ifdef __WATCOMC__
     740_Bool __bit_test_and_clear(void volatile *pvBitmap, uint32_t iBit);
     741# pragma aux __bit_test_and_clear = \
     742    "btr [edx], eax" \
     743    "sbb eax, eax" \
     744    "neg eax" \
     745    parm [edx] [eax] value [al]
     746#else
    670747static inline _Bool __bit_test_and_clear(void volatile *pvBitmap, uint32_t iBit)
    671748{
     749# ifdef _MSC_VER
     750    return _bittestandreset((long *)pvBitmap, iBit);
     751# else
    672752    union { _Bool f; uint32_t u32; } u;
    673753
    674754    __asm__ __volatile__("btrl %2, %1\n\t"
    675                          "sbbl %0, %0"
     755                         "sbbl %0, %0\n\t"
     756                         "neg %0\n\t"
    676757                         : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap)
    677758                         : "Ir" (iBit));
    678759    return u.f;
    679 }
     760#endif
     761}
     762#endif
    680763
    681764/**
     
    686769 * @param   iBit        The bit to be tested and toggled.
    687770 */
     771#ifdef __WATCOMC__
     772_Bool __bit_test_and_toggle(void volatile *pvBitmap, uint32_t iBit);
     773# pragma aux __bit_test_and_toggle = \
     774    "btc [edx], eax" \
     775    "sbb eax, eax" \
     776    "neg eax" \
     777    parm [edx] [eax] value [al]
     778#else
    688779static inline _Bool __bit_test_and_toggle(void volatile *pvBitmap, uint32_t iBit)
    689780{
     781# ifdef _MSC_VER
     782    return _bittestandcomplement((long *)pvBitmap, iBit);
     783# else
    690784    union { _Bool f; uint32_t u32; } u;
    691785
    692786    __asm__ __volatile__("btcl %2, %1\n\t"
    693                          "sbbl %0, %0"
     787                         "sbbl %0, %0\n\t"
     788                         "neg %0\n\t"
    694789                         : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap)
    695790                         : "Ir" (iBit));
    696791    return u.f;
    697 }
     792# endif
     793}
     794#endif
    698795
    699796/**
     
    703800 * @param   iBit        The bit to be set.
    704801 */
     802#ifdef __WATCOMC__
     803void __atomic_bit_set(void volatile *pvBitmap, uint32_t iBit);
     804# pragma aux __atomic_bit_set = "bts [eax], edx" parm [eax] [edx]
     805#else
    705806static inline void __atomic_bit_set(void volatile *pvBitmap, uint32_t iBit)
    706807{
    707     __asm__ __volatile__("btsl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory");
    708 }
     808# ifdef _MSC_VER
     809    _interlockedbittestandset((long *)pvBitmap, iBit);
     810# else
     811    __asm__ __volatile__("lock; btsl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory");
     812# endif
     813}
     814#endif
    709815
    710816/**
     
    714820 * @param   iBit        The bit to be cleared.
    715821 */
     822#ifdef __WATCOMC__
     823void __atomic_bit_clear(void volatile *pvBitmap, uint32_t iBit);
     824# pragma aux __atomic_bit_clear = "lock btr [eax], edx" parm [eax] [edx]
     825#else
    716826static inline void __atomic_bit_clear(void volatile *pvBitmap, uint32_t iBit)
    717827{
    718     __asm__ __volatile__("btrl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory");
    719 }
     828# ifdef _MSC_VER
     829    _interlockedbittestandreset((long *)pvBitmap, iBit);
     830# else
     831    __asm__ __volatile__("lock; btrl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory");
     832# endif
     833}
     834#endif
    720835
    721836/**
     
    725840 * @param   iBit        The bit to be cleared.
    726841 */
     842#ifdef __WATCOMC__
     843void __atomic_bit_toggle(void volatile *pvBitmap, uint32_t iBit);
     844# pragma aux __atomic_bit_toggle = "lock btc [eax], edx" parm [eax] [edx]
     845#elif defined(_MSC_VER)
     846void __atomic_bit_toggle(void volatile *pvBitmap, uint32_t iBit);
     847#else
    727848static inline void __atomic_bit_toggle(void volatile *pvBitmap, uint32_t iBit)
    728849{
    729     __asm__ __volatile__("btcl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory");
    730 }
     850    __asm__ __volatile__("lock; btcl %1, %0" : "=m" (*(uint32_t *)pvBitmap) : "Ir" (iBit) : "memory");
     851}
     852#endif
    731853
    732854/**
     
    737859 * @param   iBit        The bit to be tested and set.
    738860 */
     861#ifdef __WATCOMC__
     862_Bool __atomic_bit_test_and_set(void volatile *pvBitmap, uint32_t iBit);
     863# pragma aux __atomic_bit_test_and_set = \
     864    "lock bts [edx], eax" \
     865    "sbb eax, eax" \
     866    "neg eax" \
     867    parm [edx] [eax] value [al]
     868#else
    739869static inline _Bool __atomic_bit_test_and_set(void volatile *pvBitmap, uint32_t iBit)
    740870{
     871# ifdef _MSC_VER
     872    return _interrlockedbittestandset((long *)pvBitmap, iBit);
     873# else
    741874    union { _Bool f; uint32_t u32; } u;
    742875
    743876    __asm__ __volatile__("lock; btsl %2, %1\n\t"
    744                          "sbbl %0, %0"
     877                         "sbbl %0, %0\n\t"
     878                         "neg %0\n\t"
    745879                         : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap)
    746880                         : "Ir" (iBit));
    747881    return u.f;
    748 }
     882# endif
     883}
     884#endif
    749885
    750886/**
     
    755891 * @param   iBit        The bit to be tested and cleared.
    756892 */
     893#ifdef __WATCOMC__
     894_Bool __atomic_bit_test_and_clear(void volatile *pvBitmap, uint32_t iBit);
     895# pragma aux __atomic_bit_test_and_clear = \
     896    "lock btr [edx], eax" \
     897    "sbb eax, eax" \
     898    "neg eax" \
     899    parm [edx] [eax] value [al]
     900#else
    757901static inline _Bool __atomic_bit_test_and_clear(void volatile *pvBitmap, uint32_t iBit)
    758902{
     903# ifdef _MSC_VER
     904    return _interlockedbittestandreset((long *)pvBitmap, iBit);
     905# else
    759906    union { _Bool f; uint32_t u32; } u;
    760907
    761908    __asm__ __volatile__("lock; btrl %2, %1\n\t"
    762                          "sbbl %0, %0"
     909                         "sbbl %0, %0\n\t"
     910                         "neg %0\n\t"
    763911                         : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap)
    764912                         : "Ir" (iBit));
    765913    return u.f;
    766 }
     914# endif
     915}
     916#endif
    767917
    768918/**
     
    773923 * @param   iBit        The bit to be tested and toggled.
    774924 */
     925#ifdef __WATCOMC__
     926_Bool __atomic_bit_test_and_toggle(void volatile *pvBitmap, uint32_t iBit);
     927# pragma aux __atomic_bit_test_and_toggle = \
     928    "btc [edx], eax" \
     929    "sbb eax, eax" \
     930    "neg eax" \
     931    parm [edx] [eax] value [al]
     932#elif defined(_MSC_VER)
     933_Bool __atomic_bit_test_and_toggle(void volatile *pvBitmap, uint32_t iBit);
     934#else
    775935static inline _Bool __atomic_bit_test_and_toggle(void volatile *pvBitmap, uint32_t iBit)
    776936{
     
    778938
    779939    __asm__ __volatile__("lock; btcl %2, %1\n\t"
    780                          "sbbl %0, %0"
     940                         "sbbl %0, %0\n\t"
     941                         "neg %0\n\t"
    781942                         : "=r" (u.u32), "=m" (*(uint32_t *)pvBitmap)
    782943                         : "Ir" (iBit));
    783944    return u.f;
    784945}
     946#endif
    785947
    786948
     
    794956 * @param   cbBitmap    Size (in bytes) of the bitmap. Must be a multiple of 8.
    795957 */
     958#ifndef __GNUC__
     959int32_t __bit_scan_clear_forward(void volatile *pvBitmap, uint32_t cbBitmap);
     960#else
    796961static inline int32_t __bit_scan_clear_forward(void volatile *pvBitmap, uint32_t cbBitmap)
    797962{
     
    813978    return iBit;
    814979}
    815 
    816 
     980#endif
     981
     982
     983#ifndef __WATCOMC__ /** @todo port me later */
    817984#define __ROTATE_FUN(F,I,T) \
    818985  static __inline__ T F (T value, int shift) \
  • trunk/libc/src/kNIX/os2/386/__libc_back_envInitAsm.asm

    r3883 r3884  
    44;
    55; @copyright   Copyright (C) 2003-2014 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net>
    6 ; @licenses    MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3.
     6; @licenses    MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3, LGPLvFuture.
    77;
    88
    99
    10 %include "klibc/os2/asmdefs.mac"
     10%include "klibc/asmdefs.mac"
    1111
    12 extern __hmalloc
    13 extern __org_environ
     12extern NAME_FUNC(_hmalloc)
     13extern NAME_DATA(_org_environ)
    1414extern _STD(environ)
    1515
     
    2525; @remarks  Requires lots of stack.
    2626;
    27 global ___libc_back_envInitAsm
    28 ___libc_back_envInitAsm:
    29         push    ebp
    30         mov     esp, ebp
     27FUNC_BEGIN_WITH_FRAME __libc_back_envInitAsm
    3128        push    edi
     29FUNC_PROLOGUE_END
    3230
    3331        ;
     
    6058
    6159        push    ecx
    62         call    __hmalloc
     60        call    NAME_FUNC(_hmalloc)
    6361        add     esp, 4
    6462        or      eax, eax
    6563        jz      .return_error
    6664
    67         mov     [__org_environ], eax
     65        mov     [NAME_DATA(_org_environ)], eax
    6866        mov     [_STD(environ)], eax
    6967
     
    8179        jnz     .reverse_copy
    8280
     81FUNC_EPILOGUE
    8382.return:
    8483        lea     esp, [ebp - 4]
     
    9089        mov     eax, -1
    9190        jmp     .return
     91FUNC_END
    9292
  • trunk/libc/src/kNIX/os2/386/signal16bit.asm

    r3861 r3884  
    11; $Id$
    22;; @file
    3 ;
    43; kNIX - Signals, OS/2 16-bit handler.
    54;
    6 ; Copyright (c) 2004-2007 knut st. osmundsen <bird-src-spam@anduin.net>
    7 ;
    8 ;
    9 ; This file is part of InnoTek LIBC.
    10 ;
    11 ; InnoTek LIBC is free software; you can redistribute it and/or modify
    12 ; it under the terms of the GNU Lesser General Public License as published
    13 ; by the Free Software Foundation; either version 2 of the License, or
    14 ; (at your option) any later version.
    15 ;
    16 ; InnoTek LIBC is distributed in the hope that it will be useful,
    17 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
    18 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19 ; GNU Lesser General Public License for more details.
    20 ;
    21 ; You should have received a copy of the GNU Lesser General Public License
    22 ; along with InnoTek LIBC; if not, write to the Free Software
    23 ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    24 ;
     5; @copyright   Copyright (C) 2004-2014 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net>
     6; @licenses    MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3, LGPLvFuture.
    257;
    268
    27 %include "klibc/os2/asmdefs.mac"
     9%include "klibc/asmdefs.mac"
    2810
    2911extern Dos32TIB
    30 extern ___libc_back_signalOS2V1Handler32bit
    31 
     12extern NAME_FUNC(__libc_back_signalOS2V1Handler32bit)
    3213
    3314segment CODE16
     15
    3416;;
    3517;
     
    3719;    void FAR PASCAL __libc_back_signalOS2V1Handler16bit(USHORT sig_arg, USHORT sig_num);
    3820;
    39 global ___libc_back_signalOS2V1Handler16bit
    40 ___libc_back_signalOS2V1Handler16bit:
     21GLOBAL_FUNC __libc_back_signalOS2V1Handler16bit
     22NAME_FUNC(__libc_back_signalOS2V1Handler16bit):
    4123    ; save registers.
    4224    push    eax
     
    8466    push    eax
    8567    push    edx
    86     call    ___libc_back_signalOS2V1Handler32bit wrt FLAT
     68    call    NAME_FUNC(__libc_back_signalOS2V1Handler32bit) wrt FLAT
    8769    add     esp, 8h
    8870
     
    10991    retf    4
    11092
    111 
  • trunk/libc/src/kNIX/os2/386/thunk1.asm

    r3861 r3884  
    11; $Id$
    22;; @file
    3 ; 16-bit thunks.
     3; kNIX - 16-bit thunks.
    44;
    55; @copyright   Copyright (c) 1992-1994 by Eberhard Mattes
    66;              Copyright (C) 2004-2014 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net>
    7 ; @licenses    MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3.
     7; @licenses    MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3, LGPLvFuture.
    88;
    99
    10 %include "klibc/os2/asmdefs.mac"
     10%include "klibc/asmdefs.mac"
    1111
    1212
     
    3131; Out:  EAX     Return value (DX:AX) of 16-bit function
    3232;
    33 global __libc_thunk1
    34 __libc_thunk1:
     33GLOBAL_FUNC _libc_thunk1
     34NAME_FUNC(_libc_thunk1):
    3535%define ARGS    (2*4)                   ; Offset to ARGS relative to ebp
    3636%define FUN     (3*4)                   ; Offset to FUN relative to ebp
  • trunk/libc/src/kNIX/os2/386/unwind.asm

    r3883 r3884  
    1 ; sys/unwind.s (emx+gcc) -- Copyright (c) 1992-1994 by Eberhard Mattes
    2 ;                           Copyright (c) 2014 by Knut St. Osmundsen
     1; $Id$
     2;; @file
     3; kNIX - 16-bit thunks.
     4;
     5; @copyright   Copyright (c) 1992-1994 by Eberhard Mattes
     6;              Copyright (C) 2004-2014 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net>
     7; @licenses    MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3, LGPLvFuture.
     8;
    39
    4 %include "klibc/os2/asmdefs.mac"
     10%include "klibc/asmdefs.mac"
    511
    612extern DosUnwindException
    713
    814SEG_BEGIN_CODE
    9 ; void __unwind2 (void *xcpt_reg_ptr)
    10 global ___unwind2
    11 ___unwind2:
     15;;
     16; @cproto void __unwind2 (void *xcpt_reg_ptr)
     17;
     18GLOBAL_FUNC __unwind2
     19NAME_FUNC(__unwind2):
    1220        mov     eax, [esp + 4]
    1321        push    0
    14         push    __unwind2_continue
     22        push    .continue
    1523        push    eax
    1624        call    DosUnwindException
    17 __unwind2_continue:
     25.continue:
    1826        lea     esp, [esp + 12]
    1927        ret
  • trunk/libc/src/libc/process/psignal.c

    r3881 r3884  
    3737#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_SIGNAL
    3838#include <InnoTekLIBC/logstrict.h>
     39#include <klibc/backend.h>
    3940
    4041
  • trunk/libc/src/libc/process/tls.c

    r3881 r3884  
    3838
    3939#if ULONG_MAX == UINT_MAX
    40     /* 32 bits */
    41     #define ENTRY_BITS      32
    42     #define ENTRY_BYTES     4
    43     #define INDEX_SHIFT     5
    44     #define BIT_MASK        0x0000001f
     40/* 32 bits */
     41# define ENTRY_BITS      32
     42# define ENTRY_BYTES     4
     43# define INDEX_SHIFT     5
     44# define BIT_MASK        0x0000001f
    4545#else
    46     /* 64 bits */
    47     #define ENTRY_BITS      64
    48     #define ENTRY_BYTES     8
    49     #define INDEX_SHIFT     6
    50     #define BIT_MASK        0x000000000000003f
     46/* 64 bits */
     47# define ENTRY_BITS      64
     48# define ENTRY_BYTES     8
     49# define INDEX_SHIFT     6
     50# define BIT_MASK        0x000000000000003f
    5151#endif
    5252
Note: See TracChangeset for help on using the changeset viewer.