📄 main.c
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/lib/main.c,v 1.2 2001/11/08 15:56:22 tneale Exp $ *//* * Copyright (C) 1999-2005 Wind River Systems, Inc. * All rights reserved. Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//**************************************************************************** * Copyright 1997 Epilogue Technology Corporation. * Copyright 1998 Integrated Systems, Inc. * All rights reserved. ****************************************************************************//* * $Log: main.c,v $ * Revision 1.2 2001/11/08 15:56:22 tneale * Updated for newest file layout * * Revision 1.1.1.1 2001/11/05 17:48:41 tneale * Tornado shuffle * * Revision 1.11 2001/01/19 22:23:45 paul * Update copyright. * * Revision 1.10 2000/10/16 19:21:53 paul * Restore sockets and mempool code. * * Revision 1.9 2000/03/17 00:12:39 meister * Update copyright message * * Revision 1.8 2000/03/13 21:22:05 paul * Removed some code that we are no longer working on. * * Revision 1.7 1999/02/18 04:41:33 wes * Sockets merge: Everything Else * - memory pools * - thread support * - port-specific headers * * Revision 1.6.10.3 1998/11/13 18:17:25 wes * Make SNARK_*LOCK*() calls into the "real" attache global lock * ATTACHE_*LOCK*() and make it live in attache-land, not snark-land. * * Revision 1.6.10.2 1998/10/22 20:29:34 wes * add a `name' field to the debugging version of the mutex for added * ease of interpreting mutex assertion problems. * * Revision 1.6.10.1 1998/09/23 19:17:18 wes * Merge socket-branch-1 changes to socket-branch-2 * * Revision 1.6.8.2 1998/09/11 21:32:03 wes * Rename EPI_ prefix thread primitives to ETC_ prefix * * Revision 1.6.8.1 1998/08/19 13:26:28 wes * Merge sockets-pthreads work to shared branch * * Revision 1.6.2.1 1998/07/28 18:14:52 wes * pthread hacks * * Revision 1.6 1998/06/04 18:06:32 sra * Do psos_main() definition a slightly different way. * * Revision 1.5 1998/04/29 23:16:07 meister * SNARK_OVER_PSOS install #define * * Revision 1.4 1998/04/24 21:58:10 meister * Initial rev of pSOS snark port. * * Revision 1.3 1998/02/25 04:57:25 sra * Update copyrights. * * Revision 1.2 1997/03/20 06:52:56 sra * DFARS-safe copyright text. Zap! * * Revision 1.1 1997/02/19 08:13:05 sra * Initial revision * *//* [clearcase]modification history-------------------01a,19apr05,job update copyright notices*/#include <stdio.h>#include <stdlib.h>#include <wrn/wm/demo/snarklib.h>#if INSTALL_ATTACHE_THREADS#include <wrn/wm/attache/attthd.h>#endif/* * snark_exit() is like exit() but it first does a clean shutdown * of all the snark stuff, which might matter if you're running under purify * and care about memory leaks, or if you're running under DOS and ever want * to use your machine again without rebooting it first. */void snark_exit(int value){#if INSTALL_SNARK_EXIT_UNWIND snark_exit_flag = 1; snark_exit_value = value;#else snark_shutdown(); exit(value);#endif}/* * This is gross, but it's better than having two parameter lists to * the same function. */#if INSTALL_SNARK_OVER_PSOS#define main psos_main#endifint main(int argc, char *argv[]){ struct snark_main_args main_args; struct task initial_task; void *initial_task_cookie;#if INSTALL_ATTACHE_THREADS ATTACHE_THREAD_INIT();#endif /* * Set up argument block we pass to application's snark_main() function. * Use an explicit cookie variable so that the user-exits can muck with * it if they feel a need to do so. */ main_args.argc = argc; main_args.argv = argv; initial_task_cookie = &main_args; snark_exit_flag = snark_exit_value = 0; /* * User-exit to let application interfere before snark is running. */#ifdef SNARK_PRE_INIT_HOOK SNARK_PRE_INIT_HOOK(initial_task_cookie);#endif /* * Initialize the core of snark itself. */ snark_init(); /* * Set up the cty. Note that since we're doing this without * issuing any banner, snark_main() (or something it calls) * will have to do that "manually" later. Sorry, but we need * to set up the cty ASAP for logging, init output, etc. */ sty_listen(cty_set); CTY_SETUP(); sty_listen(0); /* * User-exit to let application interfere after snark is running. */#ifdef SNARK_POST_INIT_HOOK SNARK_POST_INIT_HOOK(initial_task_cookie);#endif /* * Set up the initial task to call the application's snark_main() function. */ task_ini(&initial_task); task_add(&initial_task, "Snark initial task", snark_main, initial_task_cookie); /* * Start running the tasking I/O system. If this ever returns, its * value is what we should use for our exit value. */ return tasks_run();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -