Ticket #2129: ugly-fastcall.patch

File ugly-fastcall.patch, 14.5 KB (added by tqh, 16 years ago)

Ugly fastcall patch

  • src/system/kernel/sem.cpp

     
    8484#define GRAB_SEM_LOCK(s)         acquire_spinlock(&(s).lock)
    8585#define RELEASE_SEM_LOCK(s)      release_spinlock(&(s).lock)
    8686
     87__attribute__((fastcall))
    8788static int remove_thread_from_sem(struct thread *thread, struct sem_entry *sem,
    8889    struct thread_queue *queue, status_t acquireStatus, bool hasThreadLock);
    8990
     
    254255    \param nextID The ID the slot will get when reused. If < 0 the \a slot
    255256           is used.
    256257*/
    257 static void
     258__attribute__((fastcall)) static void
    258259free_sem_slot(int slot, sem_id nextID)
    259260{
    260261    struct sem_entry *sem = sSems + slot;
     
    335336    thread.
    336337    The thread lock must be held when called.
    337338*/
    338 static void
     339__attribute__((fastcall)) static void
    339340fill_sem_info(struct sem_entry *sem, sem_info *info, size_t size)
    340341{
    341342    info->sem = sem->id;
     
    355356//  #pragma mark - Private Kernel API
    356357
    357358
    358 status_t
     359__attribute__((fastcall)) status_t
    359360sem_init(kernel_args *args)
    360361{
    361362    area_id area;
     
    423424    should not be made public - if possible, we should remove it
    424425    completely (and have only create_sem() exported).
    425426*/
    426 sem_id
     427__attribute__((fastcall)) sem_id
    427428create_sem_etc(int32 count, const char *name, team_id owner)
    428429{
    429430    struct sem_entry *sem = NULL;
     
    575576/*! Wake up a thread that's blocked on a semaphore
    576577    this function must be entered with interrupts disabled and THREADLOCK held
    577578*/
    578 status_t
     579__attribute__((fastcall)) status_t
    579580sem_interrupt_thread(struct thread *thread)
    580581{
    581582    struct thread_queue wakeupQueue;
     
    667668/*! This function cycles through the sem table, deleting all the sems
    668669    that are owned by the specified team.
    669670*/
    670 int
     671__attribute__((fastcall)) int
    671672sem_delete_owned_sems(team_id owner)
    672673{
    673674    int state;
  • src/system/kernel/lock.c

     
    1818#include <thread.h>
    1919
    2020
    21 int32
     21__attribute__((fastcall)) int32
    2222recursive_lock_get_recursion(recursive_lock *lock)
    2323{
    2424    if (lock->holder == thread_get_current_thread_id())
     
    2828}
    2929
    3030
    31 status_t
     31__attribute__((fastcall)) status_t
    3232recursive_lock_init(recursive_lock *lock, const char *name)
    3333{
    3434    if (lock == NULL)
     
    4848}
    4949
    5050
    51 void
     51__attribute__((fastcall)) void
    5252recursive_lock_destroy(recursive_lock *lock)
    5353{
    5454    if (lock == NULL)
     
    5959}
    6060
    6161
    62 status_t
     62__attribute__((fastcall)) status_t
    6363recursive_lock_lock(recursive_lock *lock)
    6464{
    6565    thread_id thread = thread_get_current_thread_id();
     
    7979}
    8080
    8181
    82 void
     82__attribute__((fastcall)) void
    8383recursive_lock_unlock(recursive_lock *lock)
    8484{
    8585    if (thread_get_current_thread_id() != lock->holder)
     
    9595//  #pragma mark -
    9696
    9797
    98 status_t
     98__attribute__((fastcall)) status_t
    9999mutex_init(mutex *m, const char *name)
    100100{
    101101    if (m == NULL)
     
    114114}
    115115
    116116
    117 void
     117__attribute__((fastcall)) void
    118118mutex_destroy(mutex *mutex)
    119119{
    120120    if (mutex == NULL)
     
    128128}
    129129
    130130
    131 status_t
     131__attribute__((fastcall)) status_t
    132132mutex_trylock(mutex *mutex)
    133133{
    134134    thread_id me = thread_get_current_thread_id();
     
    151151}
    152152
    153153
    154 status_t
     154__attribute__((fastcall)) status_t
    155155mutex_lock(mutex *mutex)
    156156{
    157157    thread_id me = thread_get_current_thread_id();
     
    174174}
    175175
    176176
    177 void
     177__attribute__((fastcall)) void
    178178mutex_unlock(mutex *mutex)
    179179{
    180180    thread_id me = thread_get_current_thread_id();
     
    195195//  #pragma mark -
    196196
    197197
    198 status_t
     198__attribute__((fastcall)) status_t
    199199benaphore_init(benaphore *ben, const char *name)
    200200{
    201201    if (ben == NULL || name == NULL)
     
    214214}
    215215
    216216
    217 void
     217__attribute__((fastcall)) void
    218218benaphore_destroy(benaphore *ben)
    219219{
    220220    delete_sem(ben->sem);
     
    225225//  #pragma mark -
    226226
    227227
    228 status_t
     228__attribute__((fastcall)) status_t
    229229rw_lock_init(rw_lock *lock, const char *name)
    230230{
    231231    if (lock == NULL)
     
    242242}
    243243
    244244
    245 void
     245__attribute__((fastcall)) void
    246246rw_lock_destroy(rw_lock *lock)
    247247{
    248248    if (lock == NULL)
     
    252252}
    253253
    254254
    255 status_t
     255__attribute__((fastcall)) status_t
    256256rw_lock_read_lock(rw_lock *lock)
    257257{
    258258    return acquire_sem(lock->sem);
    259259}
    260260
    261261
    262 status_t
     262__attribute__((fastcall)) status_t
    263263rw_lock_read_unlock(rw_lock *lock)
    264264{
    265265    return release_sem_etc(lock->sem, 1, 0/*B_DO_NOT_RESCHEDULE*/);
    266266}
    267267
    268268
    269 status_t
     269__attribute__((fastcall)) status_t
    270270rw_lock_write_lock(rw_lock *lock)
    271271{
    272272    return acquire_sem_etc(lock->sem, RW_MAX_READERS, 0, 0);
    273273}
    274274
    275275
    276 status_t
     276__attribute__((fastcall)) status_t
    277277rw_lock_write_unlock(rw_lock *lock)
    278278{
    279279    return release_sem_etc(lock->sem, RW_MAX_READERS, 0);
  • headers/private/kernel/condition_variable.h

     
    4343    class Private;
    4444
    4545protected:
    46             bool                Add(const void* object);
    47             status_t            Wait(uint32 flags);
    48             status_t            Wait(const void* object, uint32 flags);
     46            __attribute__((fastcall)) bool              Add(const void* object);
     47            __attribute__((fastcall)) status_t          Wait(uint32 flags);
     48            __attribute__((fastcall)) status_t          Wait(const void* object, uint32 flags);
    4949
    5050private:
    5151            void                _Remove();
     
    6868            void                Dump() const;
    6969            const void*         Object() const  { return fObject; }
    7070protected:
    71             void                Publish(const void* object,
     71            __attribute__((fastcall)) void              Publish(const void* object,
    7272                                    const char* objectType);
    73             void                Unpublish(bool threadsLocked);
    74             void                Notify(bool all, bool threadsLocked);
     73            __attribute__((fastcall)) void              Unpublish(bool threadsLocked);
     74            __attribute__((fastcall)) void              Notify(bool all, bool threadsLocked);
    7575
    7676private:
    77             void                _Notify(bool all, status_t result);
     77            __attribute__((fastcall)) void              _Notify(bool all, status_t result);
    7878
    7979protected:
    8080            typedef DoublyLinkedList<PrivateConditionVariableEntry> EntryList;
  • headers/private/kernel/kscheduler.h

     
    1313extern "C" {
    1414#endif
    1515
    16 void scheduler_enqueue_in_run_queue(struct thread *thread);
    17 void scheduler_remove_from_run_queue(struct thread *thread);
     16__attribute__((fastcall)) void scheduler_enqueue_in_run_queue(struct thread *thread);
     17__attribute__((fastcall)) void scheduler_remove_from_run_queue(struct thread *thread);
    1818void scheduler_reschedule(void);
    1919
    2020void scheduler_init(void);
  • headers/private/kernel/sem.h

     
    2020extern "C" {
    2121#endif
    2222
    23 extern status_t sem_init(struct kernel_args *args);
    24 extern int sem_delete_owned_sems(team_id owner);
    25 extern status_t sem_interrupt_thread(struct thread *t);
     23__attribute__((fastcall)) extern status_t sem_init(struct kernel_args *args);
     24__attribute__((fastcall)) extern int sem_delete_owned_sems(team_id owner);
     25__attribute__((fastcall)) extern status_t   sem_interrupt_thread(struct thread *t);
    2626extern int32 sem_used_sems(void);
    2727extern int32 sem_max_sems(void);
    2828
     
    3030extern status_t deselect_sem(int32 object, struct select_info *info,
    3131            bool kernel);
    3232
    33 extern sem_id create_sem_etc(int32 count, const char *name, team_id owner);
     33__attribute__((fastcall)) extern sem_id create_sem_etc(int32 count, const char *name, team_id owner);
    3434
    3535/* user calls */
    3636sem_id _user_create_sem(int32 count, const char *name);
  • headers/private/kernel/heap.h

     
    2222extern "C" {
    2323#endif
    2424
    25 void *memalign(size_t alignment, size_t size);
     25__attribute__((fastcall)) void *memalign(size_t alignment, size_t size);
    2626
    27 void deferred_free(void* block);
     27__attribute__((fastcall)) void deferred_free(void* block);
    2828
    29 void* malloc_referenced(size_t size);
    30 void* malloc_referenced_acquire(void* data);
    31 void malloc_referenced_release(void* data);
     29__attribute__((fastcall)) void* malloc_referenced(size_t size);
     30__attribute__((fastcall)) void* malloc_referenced_acquire(void* data);
     31__attribute__((fastcall)) void malloc_referenced_release(void* data);
    3232
    33 status_t heap_init(addr_t heapBase, size_t heapSize);
    34 status_t heap_init_post_sem();
    35 status_t heap_init_post_thread();
     33__attribute__((fastcall)) status_t heap_init(addr_t heapBase, size_t heapSize);
     34__attribute__((fastcall)) status_t heap_init_post_sem();
     35__attribute__((fastcall)) status_t heap_init_post_thread();
    3636
    3737#ifdef __cplusplus
    3838}
  • headers/private/kernel/lock.h

     
    5353extern "C" {
    5454#endif
    5555
    56 extern status_t recursive_lock_init(recursive_lock *lock, const char *name);
    57 extern void recursive_lock_destroy(recursive_lock *lock);
    58 extern status_t recursive_lock_lock(recursive_lock *lock);
    59 extern void recursive_lock_unlock(recursive_lock *lock);
    60 extern int32 recursive_lock_get_recursion(recursive_lock *lock);
     56__attribute__((fastcall)) extern status_t   recursive_lock_init(recursive_lock *lock, const char *name);
     57__attribute__((fastcall)) extern void recursive_lock_destroy(recursive_lock *lock);
     58__attribute__((fastcall)) extern status_t recursive_lock_lock(recursive_lock *lock);
     59__attribute__((fastcall)) extern void recursive_lock_unlock(recursive_lock *lock);
     60__attribute__((fastcall)) extern int32 recursive_lock_get_recursion(recursive_lock *lock);
    6161
    62 extern status_t mutex_init(mutex *m, const char *name);
    63 extern void mutex_destroy(mutex *m);
    64 extern status_t mutex_trylock(mutex *mutex);
    65 extern status_t mutex_lock(mutex *m);
    66 extern void mutex_unlock(mutex *m);
     62__attribute__((fastcall)) extern status_t   mutex_init(mutex *m, const char *name);
     63__attribute__((fastcall)) extern void mutex_destroy(mutex *m);
     64__attribute__((fastcall)) extern status_t mutex_trylock(mutex *mutex);
     65__attribute__((fastcall)) extern status_t mutex_lock(mutex *m);
     66__attribute__((fastcall)) extern void mutex_unlock(mutex *m);
    6767
    68 extern status_t benaphore_init(benaphore *ben, const char *name);
    69 extern void benaphore_destroy(benaphore *ben);
     68__attribute__((fastcall)) extern status_t benaphore_init(benaphore *ben, const char *name);
     69__attribute__((fastcall)) extern void benaphore_destroy(benaphore *ben);
    7070
    7171static inline status_t
    7272benaphore_lock_etc(benaphore *ben, uint32 flags, bigtime_t timeout)
     
    105105#endif
    106106}
    107107
    108 extern status_t rw_lock_init(rw_lock *lock, const char *name);
    109 extern void rw_lock_destroy(rw_lock *lock);
    110 extern status_t rw_lock_read_lock(rw_lock *lock);
    111 extern status_t rw_lock_read_unlock(rw_lock *lock);
    112 extern status_t rw_lock_write_lock(rw_lock *lock);
    113 extern status_t rw_lock_write_unlock(rw_lock *lock);
     108__attribute__((fastcall)) extern status_t rw_lock_init(rw_lock *lock, const char *name);
     109__attribute__((fastcall)) extern void rw_lock_destroy(rw_lock *lock);
     110__attribute__((fastcall)) extern status_t rw_lock_read_lock(rw_lock *lock);
     111__attribute__((fastcall)) extern status_t rw_lock_read_unlock(rw_lock *lock);
     112__attribute__((fastcall)) extern status_t rw_lock_write_lock(rw_lock *lock);
     113__attribute__((fastcall)) extern status_t rw_lock_write_unlock(rw_lock *lock);
    114114
    115115#ifdef __cplusplus
    116116}
  • headers/private/kernel/syscalls.h

     
    467467#ifdef __cplusplus
    468468}
    469469#endif
    470 
    471470#endif  /* _KERNEL_SYSCALLS_H */
  • headers/private/kernel/thread.h

     
    2121extern "C" {
    2222#endif
    2323
    24 void thread_enqueue(struct thread *t, struct thread_queue *q);
    25 struct thread *thread_lookat_queue(struct thread_queue *q);
    26 struct thread *thread_dequeue(struct thread_queue *q);
    27 struct thread *thread_dequeue_id(struct thread_queue *q, thread_id id);
     24__attribute__((fastcall)) void thread_enqueue(struct thread *t, struct thread_queue *q);
     25__attribute__((fastcall)) struct thread *thread_lookat_queue(struct thread_queue *q);
     26__attribute__((fastcall)) struct thread *thread_dequeue(struct thread_queue *q);
     27__attribute__((fastcall)) struct thread *thread_dequeue_id(struct thread_queue *q, thread_id id);
    2828
    29 void thread_at_kernel_entry(bigtime_t now);
     29__attribute__((fastcall)) void thread_at_kernel_entry(bigtime_t now);
    3030    // called when the thread enters the kernel on behalf of the thread
    3131void thread_at_kernel_exit(void);
    3232void thread_at_kernel_exit_no_signals(void);
    3333void thread_reset_for_exec(void);
    3434
    35 status_t thread_init(struct kernel_args *args);
    36 status_t thread_preboot_init_percpu(struct kernel_args *args, int32 cpuNum);
    37 void thread_yield(bool force);
     35__attribute__((fastcall)) status_t thread_init(struct kernel_args *args);
     36__attribute__((fastcall)) status_t thread_preboot_init_percpu(struct kernel_args *args, int32 cpuNum);
     37__attribute__((fastcall)) void thread_yield(bool force);
    3838void thread_exit(void);
    3939
    4040int32 thread_max_threads(void);
     
    4242
    4343#define thread_get_current_thread arch_thread_get_current_thread
    4444
    45 struct thread *thread_get_thread_struct(thread_id id);
    46 struct thread *thread_get_thread_struct_locked(thread_id id);
     45__attribute__((fastcall)) struct thread *thread_get_thread_struct(thread_id id);
     46__attribute__((fastcall)) struct thread *thread_get_thread_struct_locked(thread_id id);
    4747
    4848static thread_id thread_get_current_thread_id(void);
    4949static inline thread_id
     
    6262thread_id allocate_thread_id(void);
    6363thread_id peek_next_thread_id(void);
    6464
    65 thread_id spawn_kernel_thread_etc(thread_func, const char *name, int32 priority,
     65__attribute__((fastcall)) thread_id spawn_kernel_thread_etc(thread_func, const char *name, int32 priority,
    6666    void *args, team_id team, thread_id threadID);
    67 status_t wait_for_thread_etc(thread_id id, uint32 flags, bigtime_t timeout,
     67__attribute__((fastcall)) status_t wait_for_thread_etc(thread_id id, uint32 flags, bigtime_t timeout,
    6868    status_t *_returnCode);
    6969
    7070status_t select_thread(int32 object, struct select_info *info, bool kernel);