michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include michael@0: #include "nspr.h" michael@0: #include "plgetopt.h" michael@0: michael@0: /* michael@0: * Create a thread that exits right away; useful for testing race conditions in thread michael@0: * creation michael@0: */ michael@0: michael@0: int _debug_on = 0; michael@0: #define DPRINTF(arg) if (_debug_on) printf arg michael@0: michael@0: static void housecleaning(void *cur_time); michael@0: michael@0: int main (int argc, char **argv) michael@0: { michael@0: static PRIntervalTime thread_start_time; michael@0: static PRThread *housekeeping_tid = NULL; michael@0: PLOptStatus os; michael@0: PLOptState *opt = PL_CreateOptState(argc, argv, "d"); michael@0: michael@0: while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) michael@0: { michael@0: if (PL_OPT_BAD == os) continue; michael@0: switch (opt->option) michael@0: { michael@0: case 'd': /* debug mode */ michael@0: _debug_on = 1; michael@0: break; michael@0: default: michael@0: break; michael@0: } michael@0: } michael@0: PL_DestroyOptState(opt); michael@0: michael@0: if (( housekeeping_tid = michael@0: PR_CreateThread (PR_USER_THREAD, housecleaning, (void*)&thread_start_time, michael@0: PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0)) michael@0: == NULL ) { michael@0: fprintf(stderr, michael@0: "simple_test: Error - PR_CreateThread failed: (%ld, %ld)\n", michael@0: PR_GetError(), PR_GetOSError()); michael@0: exit( 1 ); michael@0: } michael@0: PR_Cleanup(); michael@0: return(0); michael@0: } michael@0: michael@0: static void michael@0: housecleaning (void *cur_time) michael@0: { michael@0: DPRINTF(("Child Thread exiting\n")); michael@0: }