| OLD | NEW |
| 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 /* ***** BEGIN LICENSE BLOCK ***** | 2 /* ***** BEGIN LICENSE BLOCK ***** |
| 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 4 * | 4 * |
| 5 * The contents of this file are subject to the Mozilla Public License Version | 5 * The contents of this file are subject to the Mozilla Public License Version |
| 6 * 1.1 (the "License"); you may not use this file except in compliance with | 6 * 1.1 (the "License"); you may not use this file except in compliance with |
| 7 * the License. You may obtain a copy of the License at | 7 * the License. You may obtain a copy of the License at |
| 8 * http://www.mozilla.org/MPL/ | 8 * http://www.mozilla.org/MPL/ |
| 9 * | 9 * |
| 10 * Software distributed under the License is distributed on an "AS IS" basis, | 10 * Software distributed under the License is distributed on an "AS IS" basis, |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 mod_init.cv = NULL; | 796 mod_init.cv = NULL; |
| 797 } | 797 } |
| 798 | 798 |
| 799 PR_IMPLEMENT(PRStatus) PR_CallOnce( | 799 PR_IMPLEMENT(PRStatus) PR_CallOnce( |
| 800 PRCallOnceType *once, | 800 PRCallOnceType *once, |
| 801 PRCallOnceFN func) | 801 PRCallOnceFN func) |
| 802 { | 802 { |
| 803 if (!_pr_initialized) _PR_ImplicitInitialization(); | 803 if (!_pr_initialized) _PR_ImplicitInitialization(); |
| 804 | 804 |
| 805 if (!once->initialized) { | 805 if (!once->initialized) { |
| 806 » if (PR_AtomicSet(&once->inProgress, 1) == 0) { | 806 » if (PR_ATOMIC_SET(&once->inProgress, 1) == 0) { |
| 807 once->status = (*func)(); | 807 once->status = (*func)(); |
| 808 PR_Lock(mod_init.ml); | 808 PR_Lock(mod_init.ml); |
| 809 once->initialized = 1; | 809 once->initialized = 1; |
| 810 PR_NotifyAllCondVar(mod_init.cv); | 810 PR_NotifyAllCondVar(mod_init.cv); |
| 811 PR_Unlock(mod_init.ml); | 811 PR_Unlock(mod_init.ml); |
| 812 } else { | 812 } else { |
| 813 PR_Lock(mod_init.ml); | 813 PR_Lock(mod_init.ml); |
| 814 while (!once->initialized) { | 814 while (!once->initialized) { |
| 815 PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT); | 815 PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT); |
| 816 } | 816 } |
| 817 PR_Unlock(mod_init.ml); | 817 PR_Unlock(mod_init.ml); |
| 818 } | 818 } |
| 819 } else { | 819 } else { |
| 820 if (PR_SUCCESS != once->status) { | 820 if (PR_SUCCESS != once->status) { |
| 821 PR_SetError(PR_CALL_ONCE_ERROR, 0); | 821 PR_SetError(PR_CALL_ONCE_ERROR, 0); |
| 822 } | 822 } |
| 823 } | 823 } |
| 824 return once->status; | 824 return once->status; |
| 825 } | 825 } |
| 826 | 826 |
| 827 PR_IMPLEMENT(PRStatus) PR_CallOnceWithArg( | 827 PR_IMPLEMENT(PRStatus) PR_CallOnceWithArg( |
| 828 PRCallOnceType *once, | 828 PRCallOnceType *once, |
| 829 PRCallOnceWithArgFN func, | 829 PRCallOnceWithArgFN func, |
| 830 void *arg) | 830 void *arg) |
| 831 { | 831 { |
| 832 if (!_pr_initialized) _PR_ImplicitInitialization(); | 832 if (!_pr_initialized) _PR_ImplicitInitialization(); |
| 833 | 833 |
| 834 if (!once->initialized) { | 834 if (!once->initialized) { |
| 835 » if (PR_AtomicSet(&once->inProgress, 1) == 0) { | 835 » if (PR_ATOMIC_SET(&once->inProgress, 1) == 0) { |
| 836 once->status = (*func)(arg); | 836 once->status = (*func)(arg); |
| 837 PR_Lock(mod_init.ml); | 837 PR_Lock(mod_init.ml); |
| 838 once->initialized = 1; | 838 once->initialized = 1; |
| 839 PR_NotifyAllCondVar(mod_init.cv); | 839 PR_NotifyAllCondVar(mod_init.cv); |
| 840 PR_Unlock(mod_init.ml); | 840 PR_Unlock(mod_init.ml); |
| 841 } else { | 841 } else { |
| 842 PR_Lock(mod_init.ml); | 842 PR_Lock(mod_init.ml); |
| 843 while (!once->initialized) { | 843 while (!once->initialized) { |
| 844 PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT); | 844 PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT); |
| 845 } | 845 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 859 PR_fprintf( | 859 PR_fprintf( |
| 860 PR_STDERR, "'%s' is obsolete. Use '%s' instead.\n", | 860 PR_STDERR, "'%s' is obsolete. Use '%s' instead.\n", |
| 861 obsolete, (NULL == preferred) ? "something else" : preferred); | 861 obsolete, (NULL == preferred) ? "something else" : preferred); |
| 862 #endif | 862 #endif |
| 863 return PR_FALSE; | 863 return PR_FALSE; |
| 864 } /* _PR_Obsolete */ | 864 } /* _PR_Obsolete */ |
| 865 | 865 |
| 866 /* prinit.c */ | 866 /* prinit.c */ |
| 867 | 867 |
| 868 | 868 |
| OLD | NEW |