blob: 4f14dbad34d600f27355edfa706f9a399fc84f0b [file] [log] [blame]
Benny Prijono9033e312005-11-21 02:08:39 +00001/* $Id$ */
2/*
3 * Copyright (C)2003-2006 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJ_DOXYGEN_H__
20#define __PJ_DOXYGEN_H__
21
22/**
23 * @file doxygen.h
24 * @brief Doxygen's mainpage.
25 */
26
27/*////////////////////////////////////////////////////////////////////////// */
28/*
29 INTRODUCTION PAGE
30 */
31
32/**
33 * @mainpage Welcome to PJLIB!
34 *
35 * @section intro_sec What is PJLIB
36 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +000037 * PJLIB is an Open Source, small footprint framework library written in C for
38 * making scalable applications. Because of its small footprint, it can be used
39 * in embedded applications (we hope so!), but yet the library is also aimed for
40 * facilitating the creation of high performance protocol stacks.
Benny Prijono9033e312005-11-21 02:08:39 +000041 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +000042 * PJLIB is released under GPL terms.
Benny Prijono9033e312005-11-21 02:08:39 +000043 *
44 * @section download_sec Download
45 *
46 * PJLIB and all documentation can be downloaded from
47 * http://www.pjproject.net.
48 *
49 *
50 * @section how_to_use_sec About This Documentation
51 *
52 * This document is generated directly from PJLIB source file using
53 * \a doxygen (http://www.doxygen.org). Doxygen is a great (and free!)
54 * tools for generating such documentation.
55 *
56 * @subsection doc_ver_subsec Version
57 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +000058 * This document corresponds to PJLIB version 0.5.6.
Benny Prijono9033e312005-11-21 02:08:39 +000059 *
60 *
61 * @subsection find_samples_subsec How to Read This Document
62 *
63 * This documentation is laid out more to be a reference guide instead
64 * of tutorial, therefore first time users may find it difficult to
65 * grasp PJLIB by reading this document alone.
66 *
67 * However, we've tried our best to make this document easy to follow.
68 * For first time users, we would suggest that you follow these steps
69 * when reading this documentation:
70 *
71 * - continue reading this introduction chapter. At the end of this
72 * chapter, you'll find section called \ref pjlib_fundamentals_sec
73 * which should guide you to understand basic things about PJLIB.
74 *
75 * - find information about specific features that you want to use
76 * in PJLIB. Use the <b>Module Index</b> to find out about all
77 * features in PJLIB (if you're browsing the HTML documentation,
78 * click on the \a Module link on top of the page, or if you're
79 * reading the PDF documentation, click on \a Module \a Documentation
80 * on the navigation pane on the left).
81 *
82 * @subsection doc_organize_sec How To's
83 *
84 * Please find below links to specific tasks that you probably
85 * want to do:
86 *
87 * - <b>How to Build PJLIB</b>
88 *\n
89 * Please refer to \ref pjlib_build_sys_pg page for more information.
90 *
91 * - <b>How to Use PJLIB in My Application</b>
92 *\n
93 * Please refer to \ref configure_app_sec for more information.
94 *
95 * - <b>How to Port PJLIB</b>
96 *\n
97 * Please refer to \ref porting_pjlib_pg page.
98 *
99 * - <b>Where to Read Samples Documentation</b>
100 *\n
101 * Most of the modules provide link to the corresponding sample file.
102 * Alternatively, to get the list of all examples, you can click on
103 * <b>Related Pages</b> on the top of HTML document or on
104 * <b>PJLIB Page Documentation</b> on navigation pane of your PDF reader.
105 *
106 * - <b>How to Submit Code to PJLIB Project</b>
107 *\n
108 * Please read \ref pjlib_coding_convention_page before submitting
109 * your code. Send your code as patch against current Subversion tree
110 * to the appropriate mailing list.
111 *
112 *
113 * @section features_sec Features
114 *
115 * @subsection open_source_feat It's Open Source!
116 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000117 * PJLIB is currently released on GPL license, but other arrangements
118 * can be made with the author.
Benny Prijono9033e312005-11-21 02:08:39 +0000119 *
120 * @subsection extreme_portable_feat Extreme Portability
121 *
122 * PJLIB is designed to be extremely portable. It can run on any kind
123 * of processors (16-bit, 32-bit, or 64-bit, big or little endian, single
124 * or multi-processors) and operating systems. Floating point or no
125 * floating point. Multi-threading or not.
126 * It can even run in environment where no ANSI LIBC is available.
127 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000128 * Currently PJLIB is known to run on these platforms:
129 * - Win32/x86 (Win95/98/ME, NT/2000/XP/2003, mingw).
130 * - arm, WinCE and Windows Mobile.
131 * - Linux/x86, (user mode and as <b>kernel module</b>(!)).
132 * - Linux/alpha
133 * - Solaris/ultra.
134 * - MacOS X/powerpc
135 * - RTEMS (x86 and powerpc).
Benny Prijono9033e312005-11-21 02:08:39 +0000136 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000137 * And efforts is under way to port PJLIB on:
138 * - Symbian OS
139 *
Benny Prijono9033e312005-11-21 02:08:39 +0000140 *
141 * @subsection small_size_feat Small in Size
142 *
143 * One of the primary objectives is to have library that is small in size for
144 * typical embedded applications. As a rough guidance, we aim to keep the
145 * library size below 100KB for it to be considered as small.
146 * As the result, most of the functionalities in the library can be tailored
147 * to meet the requirements; user can enable/disable specific functionalities
148 * to get the desired size/performance/functionality balance.
149 *
150 * For more info, please see @ref pj_config.
151 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000152 *
153 * @subsection big_perform_feat Big in Performance
154 *
155 * Almost everything in PJLIB is designed to achieve the highest possible
156 * performance out of the target platform.
157 *
158 *
Benny Prijono9033e312005-11-21 02:08:39 +0000159 * @subsection no_dyn_mem No Dynamic Memory Allocations
160 *
161 * The central idea of PJLIB is that for applications to run as fast as it can,
162 * it should not use \a malloc() at all, but instead should get the memory
163 * from a preallocated storage pool. There are few things that can be
164 * optimized with this approach:
165 *
166 * - \a alloc() is a O(1) operation.
167 * - no mutex is used inside alloc(). It is assumed that synchronization
168 * will be used in higher abstraction by application anyway.
169 * - no \a free() is required. All chunks will be deleted when the pool is
170 * destroyed.
171 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000172 * The performance gained on some systems can be as high as 30x speed up
173 * against \a malloc() and \a free() on certain configurations, but of
174 * course your mileage may vary.
Benny Prijono9033e312005-11-21 02:08:39 +0000175 *
176 * For more information, see \ref PJ_POOL_GROUP
177 *
178 *
179 * @subsection os_abstract_feat Operating System Abstraction
180 *
181 * PJLIB has abstractions for features that are normally not portable
182 * across operating systems:
183 * - @ref PJ_THREAD
184 *\n
185 * Portable thread manipulation.
186 * - @ref PJ_TLS
187 *\n
188 * Storing data in thread's private data.
189 * - @ref PJ_MUTEX
190 *\n
191 * Mutual exclusion protection.
192 * - @ref PJ_SEM
193 *\n
194 * Semaphores.
195 * - @ref PJ_ATOMIC
196 *\n
197 * Atomic variables and their operations.
198 * - @ref PJ_CRIT_SEC
199 *\n
200 * Fast locking of critical sections.
201 * - @ref PJ_LOCK
202 *\n
203 * High level abstraction for lock objects.
204 * - @ref PJ_EVENT
205 *\n
206 * Event object.
207 * - @ref PJ_TIME
208 *\n
209 * Portable time manipulation.
210 * - @ref PJ_TIMESTAMP
211 *\n
212 * High resolution time value.
213 * - etc.
214 *
215 *
216 * @subsection ll_network_io_sec Low-Level Network I/O
217 *
218 * PJLIB has very portable abstraction and fairly complete set of API for
219 * doing network I/O communications. At the lowest level, PJLIB provides:
220 *
221 * - @ref PJ_SOCK
222 *\n
223 * A highly portable socket abstraction, runs on all kind of
224 * network APIs such as standard BSD socket, Windows socket, Linux
225 * \b kernel socket, PalmOS networking API, etc.
226 *
227 * - @ref pj_addr_resolve
228 *\n
229 * Portable address resolution, which implements #pj_gethostbyname().
230 *
231 * - @ref PJ_SOCK_SELECT
232 *\n
233 * A portable \a select() like API (#pj_sock_select()) which can be
234 * implemented with various back-end.
235 *
236 *
237 * @subsection hl_network_io_sec High-Level Network I/O
238 *
239 * At higher abstraction, PJLIB provides @ref PJ_IOQUEUE,
240 * which promotes creating high performance network
241 * applications by managing asynchronous I/O. This is a passive framework
242 * that utilizes the most effective way to manage asynchronous I/O
243 * on a given platform, such as:
244 * - IoCompletionPort on WinNT,
245 * - on Linux it can use either /dev/epoll or aio.
246 * - or to fall back to use @a select()
247 *
248 * At even a higher abstraction, PJLIB provides @ref PJ_EQUEUE, which
249 * combines asynchronous I/O with timer management and thread management
250 * to fasilitate creating trully high performance, event driven
251 * application.
252 *
253 *
254 * @subsection timer_mgmt_sec Timer Management
255 *
256 * A passive framework for managing timer, see @ref PJ_TIMER for more info.
257 * There is also function to retrieve high resolution timestamp
258 * from the system (see @ref PJ_TIMESTAMP).
259 *
260 *
261 * @subsection data_struct_sec Various Data Structures
262 *
263 * Various data structures are provided in the library:
264 *
265 * - @ref PJ_PSTR
266 * - @ref PJ_ARRAY
267 * - @ref PJ_HASH
268 * - @ref PJ_LIST
269 * - @ref PJ_RBTREE
270 *
271 *
272 * @subsection exception_sec Exception Construct
273 *
274 * A convenient TRY/CATCH like construct to propagate errors, which by
275 * default are used by the @ref PJ_POOL_GROUP "memory pool" and
276 * the lexical scanner in pjlib-util. The exception
277 * construct can be used to write programs like below:
278 *
279 * <pre>
280 * #define SYNTAX_ERROR 1
281 *
282 * PJ_TRY {
283 * msg = NULL;
284 * msg = parse_msg(buf, len);
285 * }
286 * PJ_CATCH ( SYNTAX_ERROR ) {
287 * .. handle error ..
288 * }
289 * PJ_END;
290 * </pre>
291 *
292 * Please see @ref PJ_EXCEPT for more information.
293 *
294 *
295 * @subsection logging_sec Logging Facility
296 *
297 * PJLIB @ref PJ_LOG consists of macros to write logging information to
298 * some output device. Some of the features of the logging facility:
299 *
300 * - the verbosity can be fine-tuned both at compile time (to control
301 * the library size) or run-time (to control the verbosity of the
302 * information).
303 * - output device is configurable (e.g. stdout, printk, file, etc.)
304 * - log decoration is configurable.
305 *
306 * See @ref PJ_LOG for more information.
307 *
308 *
309 * @subsection guid_gen_sec Random and GUID Generation
310 *
311 * PJLIB provides facility to create random string
312 * (#pj_create_random_string()) or globally unique identifier
313 * (see @ref PJ_GUID).
314 *
315 *
316 *
317 * @section configure_app_sec Configuring Application to use PJLIB
318 *
319 * @subsection pjlib_compil_sec Building PJLIB
320 *
321 * Follow the instructions in \ref pjlib_build_sys_pg to build
322 * PJLIB.
323 *
324 * @subsection pjlib_compil_app_sec Building Applications with PJLIB
325 *
326 * Use the following settings when building applications with PJLIB.
327 *
328 * @subsubsection compil_inc_dir_sec Include Search Path
329 *
330 * Add this to your include search path ($PJLIB is PJLIB root directory):
331 * <pre>
332 * $PJLIB/include
333 * </pre>
334 *
335 * @subsubsection compil_inc_file_sec Include PJLIB Header
336 *
337 * To include all PJLIB headers:
338 * \verbatim
339 #include <pjlib.h>
340 \endverbatim
341 *
342 * Alternatively, you can include individual PJLIB headers like this:
343 * \verbatim
344 #include <pj/log.h>
345 #include <pj/os.h>
346 \endverbatim
347 *
348 *
349 * @subsubsection compil_lib_dir_sec Library Path
350 *
351 * Add this to your library search path:
352 * <pre>
353 * $PJLIB/lib
354 * </pre>
355 *
356 * Then add the appropriate PJLIB library to your link specification. For
357 * example, you would add \c libpj-i386-linux-gcc.a when you're building
358 * applications in Linux.
359 *
360 *
361 * @subsection pjlib_fundamentals_sec Principles in Using PJLIB
362 *
363 * Few things that you \b MUST do when using PJLIB, to make sure that
364 * you create trully portable applications.
365 *
366 * @subsubsection call_pjlib_init_sec Call pj_init()
367 *
368 * Before you do anything else, call \c pj_init(). This would make sure that
369 * PJLIB system is properly set up.
370 *
371 * @subsubsection no_ansi_subsec Do NOT Use ANSI C
372 *
373 * Contrary to popular teaching, ANSI C (and LIBC) is not the most portable
374 * library in the world, nor it's the most ubiquitous. For example, LIBC
375 * is not available in Linux kernel. Also normally LIBC will be excluded
376 * from compilation of RTOSes to reduce size.
377 *
378 * So for maximum portability, do NOT use ANSI C. Do not even try to include
379 * any other header files outside <include/pj>. Stick with the functionalities
380 * provided by PJLIB.
381 *
382 *
383 * @subsubsection string_rep_subsubsec Use pj_str_t instead of C Strings
384 *
385 * PJLIB uses pj_str_t instead of normal C strings. You SHOULD follow this
386 * convention too. Remember, ANSI string-h is not always available. And
387 * PJLIB string is faster!
388 *
389 * @subsubsection mem_alloc_subsubsec Use Pool for Memory Allocations
390 *
391 * You MUST NOT use \a malloc() or any other memory allocation functions.
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000392 * Use PJLIB @ref PJ_POOL_GROUP instead! It's faster and most portable.
Benny Prijono9033e312005-11-21 02:08:39 +0000393 *
394 * @subsection logging_subsubsec Use Logging for Text Display
395 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000396 * DO NOT use <stdio.h> for text output. Use PJLIB @ref PJ_LOG instead.
Benny Prijono9033e312005-11-21 02:08:39 +0000397 *
398 *
399 * @section porting_pjlib_sec0 Porting PJLIB
400 *
401 * Please see \ref porting_pjlib_pg page on more information to port
402 * PJLIB to new target.
403 *
404 * @section enjoy_sec Enjoy Using PJLIB!
405 *
406 * We hope that you find PJLIB usefull for your application. If you
407 * have any questions, suggestions, critics, bug fixes, or anything
408 * else, we would be happy to hear it.
409 *
410 * Enjoy using PJLIB!
411 *
412 * Benny Prijono < bennylp at pjproject dot net >
413 */
414
415
416
417/*////////////////////////////////////////////////////////////////////////// */
418/*
419 CODING CONVENTION
420 */
421
422/**
423 * @page pjlib_coding_convention_page Coding Convention
424 *
425 * Before you submit your code/patches to be included with PJLIB, you must
426 * make sure that your code is compliant with PJLIB coding convention.
427 * <b>This is very important!</b> Otherwise we would not accept your code.
428 *
429 * @section coding_conv_editor_sec Editor Settings
430 *
431 * The single most important thing in the whole coding convention is editor
432 * settings. It's more important than the correctness of your code (bugs will
433 * only crash the system, but incorrect tab size is mental!).
434 *
435 * Kindly set your editor as follows:
436 * - tab size to \b 8.
437 * - indentation to \b 4.
438 *
439 * With \c vi, you can do it with:
440 * <pre>
441 * :se ts=8
442 * :se sts=4
443 * </pre>
444 *
445 * You should replace tab with eight spaces.
446 *
447 * @section coding_conv_detail_sec Coding Style
448 *
449 * Coding style MUST strictly follow K&R style. The rest of coding style
450 * must follow current style. You SHOULD be able to observe the style
451 * currently used by PJLIB from PJLIB sources, and apply the style to your
452 * code. If you're not able to do simple thing like to observe PJLIB
453 * coding style from the sources, then logic dictates that your ability to
454 * observe more difficult area in PJLIB such as memory allocation strategy,
455 * concurrency, etc is questionable.
456 *
457 * @section coding_conv_comment_sec Commenting Your Code
458 *
459 * Public API (e.g. in header files) MUST have doxygen compliant comments.
460 *
461 */
462
463
464/*////////////////////////////////////////////////////////////////////////// */
465/*
466 BUILDING AND INSTALLING PJLIB
467 */
468
469
470
471/**
472 * @page pjlib_build_sys_pg Building, and Installing PJLIB
473 *
474 * @section build_sys_install_sec Build and Installation
475 *
476 * @subsection build_sys_install_win32_sec Visual Studio
477 *
478 * The PJLIB Visual Studio workspace supports the building of PJLIB
479 * for Win32 target. Although currently only the Visual Studio 6 Workspace is
480 * actively maintained, developers with later version of Visual Studio
481 * can easily imports VS6 workspace into their IDE.
482 *
483 * To start building PJLIB projects with Visual Studio 6 or later, open
484 * the \a workspace file in the corresponding \b \c build directory. You have
485 * several choices on which \a dsw file to open:
486 \verbatim
487 $PJPROJECT/build/pjproject.dsw
488 $PJPROJECT/pjlib/build/pjlib.dsw
489 $PJPROJECT/pjsip/build/pjsip.dsw
490 ..etc
491 \endverbatim
492 *
493 * The easiest way is to open <tt>pjproject.dsw</tt> file in \b \c $PJPROJECT/build
494 * directory. However this will only build the required projects, not
495 * the complete projects. For example, the PJLIB test and samples projects
496 * are not included in this workspace. To build the complete projects, you must
497 * open and build each \a dsw file in \c build directory in each
498 * subprojects. For example, to open the complete PJLIB workspace, open
499 * <tt>pjlib.dsw</tt> in <tt>$PJPROJECT/pjlib/build</tt> directory.
500 *
501 *
502 * @subsubsection config_site_create_vc_sec Create config_site.h
503 *
504 * The file <tt><b>$PJPROJECT/pjlib/include/pj/config_site.h</b></tt>
505 * is supposed to contain configuration that is specific to your site/target.
506 * This file is not part of PJLIB, so you must create it yourself. Normally
507 * you just need to create a blank file.
508 *
509 * The reason why it's not included in PJLIB is so that you would not accidently
510 * overwrite your site configuration.
511 *
512 * If you fail to do this, Visual C will complain with error like:
513 *
514 * <b>"fatal error C1083: Cannot open include file: 'pj/config_site.h': No such file
515 * or directory"</b>.
516 *
517 * @subsubsection build_vc_subsubsec Build the Projects
518 *
519 * Just hit the build button!
520 *
521 *
522 * @subsection build_sys_install_unix_sec Make System
523 *
524 * For other targets, PJLIB provides a rather comprehensive build system
525 * that uses GNU \a make (and only GNU \a make will work).
526 * Currently, the build system supports building * PJLIB for these targets:
527 * - i386/Win32/mingw
528 * - i386/Linux
529 * - i386/Linux (kernel)
530 * - alpha/linux
531 * - sparc/SunOS
532 * - etc..
533 *
534 *
535 * @subsubsection build_req_sec Requirements
536 *
537 * In order to use the \c make based build system, you MUST have:
538 *
539 * - <b>GNU make</b>
540 *\n
541 * The Makefiles heavily utilize GNU make commands which most likely
542 * are not available in other \c make system.
543 * - <b>bash</b> shell is recommended.
544 *\n
545 * Specificly, there is a command <tt>"echo -n"</tt> which may not work
546 * in other shells. This command is used when generating dependencies
547 * (<tt>make dep</tt>) and it's located in
548 * <tt>$PJPROJECT/build/rules.mak</tt>.
549 * - <b>ar</b>, <b>ranlib</b> from GNU binutils
550 *\n
551 * In your system has different <tt>ar</tt> or <tt>ranlib</tt> (e.g. they
552 * may have been installed as <tt>gar</tt> and <tt>granlib</tt>), then
553 * either you create the relevant symbolic links, <b>or</b> modify
554 * <tt>$PJPROJECT/build/cc-gcc.mak</tt> and rename <tt>ar</tt> and
555 * <tt>ranlib</tt> to the appropriate names.
556 * - <b>gcc</b> to generate dependency.
557 *\n
558 * Currently the build system uses <tt>"gcc -MM"</tt> to generate build
559 * dependencies. If <tt>gcc</tt> is not desired to generate dependency,
560 * then either you don't run <tt>make dep</tt>, <b>or</b> edit
561 * <tt>$PJPROJECT/build/rules.mak</tt> to calculate dependency using
562 * your prefered method. (And let me know when you do so so that I can
563 * update the file. :) )
564 *
565 * @subsubsection build_overview_sec Building the Project
566 *
567 * Generally, steps required to build the PJLIB are:
568 *
569 \verbatim
570 $ cd /home/user/pjproject # <-- go to $PJPROJECT
571 $ vi build.mak # <-- set build target etc
572 $ touch pjlib/include/pj/config_site.h
573 $ cd pjlib/build # <-- go to projet's build dir
574 $ make # <-- build the project
575 \endverbatim
576 *
577 * For other project, \a cd to <tt>build</tt> directory in the project
578 * and execute \a make from there.
579 *
580 * \note For Linux kernel target, there are additional steps required, which
581 * will be explained in section \ref linux_kern_target_subsec.
582 *
583 * @subsubsection build_mak_sec Editing build.mak
584 *
585 * The \c build.mak file in \c $PJPROJECT root directory is used to
586 * specify the build configuration. This file is expected to export
587 * the following \a make variables:
588 *
589 * - <tt><b>MACHINE_NAME</b></tt>
590 *\n
591 * Target machine/processor, one of: <b>{ i386 | alpha | sparc }</b>.
592 *
593 * - <tt><b>OS_NAME</b></tt>
594 *\n
595 * Target operating system, one of: <b>{ win32 | linux |
596 * linux-kernel | sunos }</b>.
597 *
598 * - <tt><b>CC_NAME</b></tt>
599 *\n
600 * Compiler name: <b>{ gcc | vc }</b>\n
601 * (Note that support for Visual C (vc) compiler with the \c make system is
602 * experimental, and it will only work when run inside a DOS shell
603 * (i.e. <tt>"HOST_NAME=win32"</tt>)).
604 *
605 * - <tt><b>HOST_NAME</b></tt>
606 *\n
607 * Build host: <b>{ unix | mingw | win32 }</b>\n
608 * (Note: win32 host means a DOS command prompt. Support for this type
609 * of development host is experimental).
610 *
611 * These variables will cause the correct configuration file in
612 * \c $PJPROJECT/build directory to be executed by \a make. For
613 * example, specifying \c OS_NAME=linux will cause file \c os-linux.mak
614 * in \c build directory to be executed. These files contain specific
615 * configuration for the option that is selected.
616 *
617 * For Linux kernel target, you are also required to declare the following
618 * variables in this file:
619 * - \c KERNEL_DIR: full path of kernel source tree.
620 * - \c KERNEL_ARCH: kernel ARCH options (e.g. "ARCH=um"), or leave blank
621 * for default.
622 * - \c PJPROJECT_DIR: full path of PJPROJECT source tree.
623 *
624 * Apart from these, there are also additional steps required to build
625 * Linux kernel target, which will be explained in \ref linux_kern_target_subsec.
626 *
627 * @subsubsection build_dir_sec Files in "build" Directory
628 *
629 * The <tt>*.mak</tt> files in \c $PJPROJECT/build directory are used to specify
630 * the configuration for the specified compiler, target machine target
631 * operating system, and host options. These files will be executed
632 * (included) by \a make during building process, depending on the values
633 * specified in <b>$PJPROJECT/build.mak</b> file.
634 *
635 * Normally you don't need to edit these files, except when you're porting
636 * PJLIB to new target.
637 *
638 * Below are the description of some files in this directory:
639 *
640 * - <tt>rules.mak</tt>: contains generic rules always included during make.
641 * - <tt>cc-gcc.mak</tt>: rules when gcc is used for compiler.
642 * - <tt>cc-vc.mak</tt>: rules when MSVC compiler is used.
643 * - <tt>host-mingw.mak</tt>: rules for building in mingw host.
644 * - <tt>host-unix.mak</tt>: rules for building in Unix/Posix host.
645 * - <tt>host-win32.mak</tt>: rules for building in Win32 command console
646 * (only valid when VC is used).
647 * - <tt>m-i386.mak</tt>: rules when target machine is an i386 processor.
648 * - <tt>m-m68k.mak</tt>: rules when target machine is an m68k processor.
649 * - <tt>os-linux.mak</tt>: rules when target OS is Linux.
650 * - <tt>os-linux-kernel.mak</tt>: rules when PJLIB is to be build as
651 * part of Linux kernel.
652 * - <tt>os-win32.mak</tt>: rules when target OS is Win32.
653 *
654 *
655 * @subsubsection config_site_create_sec Create config_site.h
656 *
657 * The file <tt><b>$PJPROJECT/pjlib/include/pj/config_site.h</b></tt>
658 * is supposed to contain configuration that is specific to your site/target.
659 * This file is not part of PJLIB, so you must create it yourself.
660 *
661 * The reason why it's not included in PJLIB is so that you would not accidently
662 * overwrite your site configuration.
663 *
664 *
665 * @subsubsection invoking_make_sec Invoking make
666 *
667 * Normally, \a make is invoked in \c build directory under each project.
668 * For example, to build PJLIB, you would invoke \a make in
669 * \c $PJPROJECT/pjlib/build directory like below:
670 *
671 \verbatim
672 $ cd pjlib/build
673 $ make
674 \endverbatim
675 *
676 * Alternatively you may invoke <tt>make</tt> in <tt>$PJPROJECT</tt>
677 * directory, to build all projects under that directory (e.g.
678 * PJLIB, PJSIP, etc.).
679 *
680 *
681 * @subsubsection linux_kern_target_subsec Linux Kernel Target
682 *
683 * \note
684 * <b>BUILDING APPLICATIONS IN LINUX KERNEL MODE IS A VERY DANGEROUS BUSINESS.
685 * YOU MAY CRASH THE WHOLE OF YOUR SYSTEM, CORRUPT YOUR HARDISK, ETC. PJLIB
686 * KERNEL MODULES ARE STILL IN EXPERIMENTAL PHASE. DO NOT RUN IT IN PRODUCTION
687 * SYSTEMS OR OTHER SYSTEMS WHERE RISK OF LOSS OF DATA IS NOT ACCEPTABLE.
688 * YOU HAVE BEEN WARNED.</b>
689 *
690 * \note
691 * <b>User Mode Linux (UML)</b> provides excellent way to experiment with Linux
692 * kernel without risking the stability of the host system. See
693 * http://user-mode-linux.sourceforge.net for details.
694 *
695 * \note
696 * I only use <b>UML</b> to experiment with PJLIB kernel modules.
697 * <b>I wouldn't be so foolish to use my host Linux machine to experiment
698 * with this.</b>
699 *
700 * \note
701 * You have been warned.
702 *
703 * For building PJLIB for Linux kernel target, there are additional steps required.
704 * In general, the additional tasks are:
705 * - Declare some more variables in <b><tt>build.mak</tt></b> file (this
706 * has been explained in \ref build_mak_sec above).
707 * - Perform these two small modifications in kernel source tree.
708 *
709 * There are two small modification need to be applied to the kernel tree.
710 *
711 * <b>1. Edit <tt>Makefile</tt> in kernel root source tree.</b>
712 *
713 * Add the following lines at the end of the <tt>Makefile</tt> in your
714 * <tt>$KERNEL_SRC</tt> dir:
715 \verbatim
716script:
717 $(SCRIPT)
718 \endverbatim
719 *
720 * \note Remember to replace spaces with <b>tab</b> in the Makefile.
721 *
722 * The modification above is needed to capture kernel's \c $CFLAGS and
723 * \c $CFLAGS_MODULE which will be used for PJLIB's compilation.
724 *
725 * <b>2. Add Additional Exports.</b>
726 *
727 * We need the kernel to export some more symbols for our use. So we declare
728 * the additional symbols to be exported in <tt>extra-exports.c</tt> file, and add
729 * a this file to be compiled into the kernel:
730 *
731 * - Copy the file <tt>extra-exports.c</tt> from <tt>pjlib/src/pj</tt>
732 * directory to <tt>$KERNEL_SRC/kernel/</tt> directory.
733 * - Edit <tt>Makefile</tt> in that directory, and add this line
734 * somewhere after the declaration of that variable:
735 \verbatim
736obj-y += extra-exports.o
737 \endverbatim
738 *
739 * To illustrate what have been done in your kernel source tree, below
740 * is screenshot of my kernel source tree _after_ the modification.
741 *
742 \verbatim
743[root@vpc-linux linux-2.6.7]# pwd
744/usr/src/linux-2.6.7
745[root@vpc-linux linux-2.6.7]#
746[root@vpc-linux linux-2.6.7]#
747[root@vpc-linux linux-2.6.7]# tail Makefile
748
749endif # skip-makefile
750
751FORCE:
752
753.PHONY: script
754
755script:
756 $(SCRIPT)
757
758[root@vpc-linux linux-2.6.7]#
759[root@vpc-linux linux-2.6.7]#
760[root@vpc-linux linux-2.6.7]# head kernel/extra-exports.c
761#include <linux/module.h>
762#include <linux/syscalls.h>
763
764EXPORT_SYMBOL(sys_select);
765
766EXPORT_SYMBOL(sys_epoll_create);
767EXPORT_SYMBOL(sys_epoll_ctl);
768EXPORT_SYMBOL(sys_epoll_wait);
769
770EXPORT_SYMBOL(sys_socket);
771[root@vpc-linux linux-2.6.7]#
772[root@vpc-linux linux-2.6.7]#
773[root@vpc-linux linux-2.6.7]# head -15 kernel/Makefile
774#
775# Makefile for the linux kernel.
776#
777
778obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
779 exit.o itimer.o time.o softirq.o resource.o \
780 sysctl.o capability.o ptrace.o timer.o user.o \
781 signal.o sys.o kmod.o workqueue.o pid.o \
782 rcupdate.o intermodule.o extable.o params.o posix-timers.o \
783 kthread.o
784
785obj-y += extra-exports.o
786
787obj-$(CONFIG_FUTEX) += futex.o
788obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
789[root@vpc-linux linux-2.6.7]#
790
791 \endverbatim
792 *
793 * Then you must rebuild the kernel.
794 * If you fail to do this, you won't be able to <b>insmod</b> pjlib.
795 *
796 * \note You will see a lots of warning messages during pjlib-test compilation.
797 * The warning messages complain about unresolved symbols which are defined
798 * in pjlib module. You can safely ignore these warnings. However, you can not
799 * ignore warnings about non-pjlib unresolved symbols.
800 *
801 *
802 * @subsection makefile_explained_sec Makefile Explained
803 *
804 * The \a Makefile for each project (e.g. PJLIB, PJSIP, etc) should be
805 * very similar in the contents. The Makefile is located under \c build
806 * directory in each project subdir.
807 *
808 * @subsubsection pjlib_makefile_subsec PJLIB Makefile.
809 *
810 * Below is PJLIB's Makefile:
811 *
812 * \include build/Makefile
813 *
814 * @subsubsection pjlib_os_makefile_subsec PJLIB os-linux.mak.
815 *
816 * Below is file <tt><b>os-linux.mak</b></tt> file in
817 * <tt>$PJPROJECT/pjlib/build</tt> directory,
818 * which is OS specific configuration file for Linux target that is specific
819 * for PJLIB project. For \b global OS specific configuration, please see
820 * <tt>$PJPROJECT/build/os-*.mak</tt>.
821 *
822 * \include build/os-linux.mak
823 *
824 */
825
826
827/*////////////////////////////////////////////////////////////////////////// */
828/*
829 PORTING PJLIB
830 */
831
832
833
834/**
835 * @page porting_pjlib_pg Porting PJLIB
836 *
837 *
838 * @section new_arch_sec Porting to New CPU Architecture
839 *
840 * Below is step-by-step guide to add support for new CPU architecture.
841 * This sample is based on porting to Alpha architecture; however steps for
842 * porting to other CPU architectures should be pretty similar.
843 *
844 * Also note that in this example, the operating system used is <b>Linux</b>.
845 * Should you wish to add support for new operating system, then follow
846 * the next section \ref porting_os_sec.
847 *
848 * Step-by-step guide to port to new CPU architecture:
849 * - decide the name for the new architecture. In this case, we choose
850 * <tt><b>alpha</b></tt>.
851 * - edit file <tt>$PJPROJECT/build.mak</tt>, and add new section for
852 * the new target:
853 * <pre>
854 * #
855 * # Linux alpha, gcc
856 * #
857 * export MACHINE_NAME := <b>alpha</b>
858 * export OS_NAME := linux
859 * export CC_NAME := gcc
860 * export HOST_NAME := unix
861 * </pre>
862 *
863 * - create a new file <tt>$PJPROJECT/build/<b>m-alpha</b>.mak</tt>.
864 * Alternatively create a copy from other file in this directory.
865 * The contents of this file will look something like:
866 * <pre>
867 * export M_CFLAGS := $(CC_DEF)<b>PJ_M_ALPHA=1</b>
868 * export M_CXXFLAGS :=
869 * export M_LDFLAGS :=
870 * export M_SOURCES :=
871 * </pre>
872 * - create a new file <tt>$PJPROJECT/pjlib/include/pj/compat/<b>m_alpha.h</b></tt>.
873 * Alternatively create a copy from other header file in this directory.
874 * The contents of this file will look something like:
875 * <pre>
876 * #define PJ_HAS_PENTIUM 0
877 * #define PJ_IS_LITTLE_ENDIAN 1
878 * #define PJ_IS_BIG_ENDIAN 0
879 * </pre>
880 * - edit <tt>pjlib/include/pj/<b>config.h</b></tt>. Add new processor
881 * configuration in this header file, like follows:
882 * <pre>
883 * ...
884 * #elif defined (PJ_M_ALPHA) && PJ_M_ALPHA != 0
885 * # include <pj/compat/m_alpha.h>
886 * ...
887 * </pre>
888 * - done. Build PJLIB with:
889 * <pre>
890 * $ cd $PJPROJECT/pjlib/build
891 * $ make dep
892 * $ make clean
893 * $ make
894 * </pre>
895 *
896 * @section porting_os_sec Porting to New Operating System Target
897 *
898 * This section will try to give you rough guideline on how to
899 * port PJLIB to a new target. As a sample, we give the target a name tag,
900 * for example <tt><b>xos</b></tt> (for X OS).
901 *
902 * @subsection new_compat_os_h_file_sec Create New Compat Header File
903 *
904 * You'll need to create a new header file
905 * <b><tt>include/pj/compat/os_xos.h</tt></b>. You can copy as a
906 * template other header file and edit it accordingly.
907 *
908 * @subsection modify_config_h_file_sec Modify config.h
909 *
910 * Then modify file <b><tt>include/pj/config.h</tt></b> to include
911 * this file accordingly (e.g. when macro <tt><b>PJ_XOS</b></tt> is
912 * defined):
913 *
914 \verbatim
915 ...
916 #elif defined(PJ_XOS)
917 # include <pj/compat/os_xos.h>
918 #else
919 #...
920 \endverbatim
921 *
922 * @subsection new_target_mak_file_sec Create New Global Make Config File
923 *
924 * Then you'll need to create global configuration file that
925 * is specific for this OS, i.e. <tt><b>os-xos.mak</b></tt> in
926 * <tt><b>$PJPROJECT/build</b></tt> directory.
927 *
928 * At very minimum, the file will normally need to define
929 * <tt><b>PJ_XOS=1</b></tt> in the \c CFLAGS section:
930 *
931 \verbatim
932#
933# $PJPROJECT/build/os-xos.mak:
934#
935export OS_CFLAGS := $(CC_DEF)PJ_XOS=1
936export OS_CXXFLAGS :=
937export OS_LDFLAGS :=
938export OS_SOURCES :=
939 \endverbatim
940 *
941 *
942 * @subsection new_target_prj_mak_file_sec Create New Project's Make Config File
943 *
944 * Then you'll need to create xos-specific configuration file
945 * for PJLIB. This file is also named <tt><b>os-xos.mak</b></tt>,
946 * but its located in <tt><b>pjlib/build</b></tt> directory.
947 * This file will specify source files that are specific to
948 * this OS to be included in the build process.
949 *
950 * Below is a sample:
951 \verbatim
952#
953# pjlib/build/os-xos.mak:
954# XOS specific configuration for PJLIB.
955#
956export PJLIB_OBJS += os_core_xos.o \
957 os_error_unix.o \
958 os_time_ansi.o
959export TEST_OBJS += main.o
960export TARGETS = pjlib pjlib-test
961 \endverbatim
962 *
963 * @subsection new_target_src_sec Create and Edit Source Files
964 *
965 * You'll normally need to create at least these files:
966 * - <tt><b>os_core_xos.c</b></tt>: core OS specific
967 * functionality.
968 * - <tt><b>os_timestamp_xos.c</b></tt>: how to get timestamp
969 * in this OS.
970 *
971 * Depending on how things are done in your OS, you may need
972 * to create these files:
973 * - <tt><b>os_error_*.c</b></tt>: how to manipulate
974 * OS error codes. Alternatively you may use existing
975 * <tt>os_error_unix.c</tt> if the OS has \c errno and
976 * \c strerror() function.
977 * - <tt><b>ioqueue_*.c</b></tt>: if the OS has specific method
978 * to perform asynchronous I/O. Alternatively you may
979 * use existing <tt>ioqueue_select.c</tt> if the OS supports
980 * \c select() function call.
981 * - <tt><b>sock_*.c</b></tt>: if the OS has specific method
982 * to perform socket communication. Alternatively you may
983 * use existing <tt>sock_bsd.c</tt> if the OS supports
984 * BSD socket API, and edit <tt>include/pj/compat/socket.h</tt>
985 * file accordingly.
986 *
987 * You will also need to check various files in
988 * <tt><b>include/pj/compat/*.h</b></tt>, to see if they're
989 * compatible with your OS.
990 *
991 * @subsection new_target_build_file_sec Build The Project
992 *
993 * After basic building blocks have been created for the OS, then
994 * the easiest way to see which parts need to be fixed is by building
995 * the project and see the error messages.
996 *
997 * @subsection new_target_edit_vs_new_file_sec Editing Existing Files vs Creating New File
998 *
999 * When you encounter compatibility errors in PJLIB during porting,
1000 * you have three options on how to fix the error:
1001 * - edit the existing <tt>*.c</tt> file, and give it <tt>#ifdef</tt>
1002 * switch for the new OS, or
1003 * - edit <tt>include/pj/compat/*.h</tt> instead, or
1004 * - create a totally new file.
1005 *
1006 * Basicly there is no strict rule on which approach is the best
1007 * to use, however the following guidelines may be used:
1008 * - if the file is expected to be completely different than
1009 * any existing file, then perhaps you should create a completely
1010 * new file. For example, file <tt>os_core_xxx.c</tt> will
1011 * normally be different for each OS flavour.
1012 * - if the difference can be localized in <tt>include/compat</tt>
1013 * header file, and existing <tt>#ifdef</tt> switch is there,
1014 * then preferably you should edit this <tt>include/compat</tt>
1015 * header file.
1016 * - if the existing <tt>*.c</tt> file has <tt>#ifdef</tt> switch,
1017 * then you may add another <tt>#elif</tt> switch there. This
1018 * normally is used for behaviors that are not totally
1019 * different on each platform.
1020 * - other than that above, use your own judgement on whether
1021 * to edit the file or create new file etc.
1022 */
1023
1024#endif /* __PJ_DOXYGEN_H__ */
1025