Читаем UNIX: взаимодействие процессов полностью

111 #define MAXLINE 4096 /* максимальная длина строки */

112 #define BUFFSI2E 8192 /* объем буфера чтения и записи */

113 #define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)

114  /* разрешения по умолчанию для новых файлов */

115 #define DIR_MODE (FILE_MODE | S_IXUSR | S_IXGRP | S_IXOTH)

116  /* разрешения по умолчанию для новых каталогов */

117 #define SVMSG_MODE (MSG_R | MSG_W | MSG_R>>3 | MSG_R>>6)

118  /* разрешения по умолчанию для новых очередей сообщений System V */

119 #define SVSEM_MODE (SEM_R | SEM_A | SEM_R>>3 | SEM_R>>6)

120  /* разрешения по умолчанию для новых семафоров System V */

121 #define SVSHM_MODE (SHM_R | SHM_W | SHM_R>>3 | SHM_R>>6)

122  /* разрешения по умолчанию для новой разделяемой памяти System V */


123 typedef void Sigfunc(int); /* для обработчиков сигналов */

124 #ifdef HAVE_SIGINFO_T_STRUCT

125 typedef void Sigfunc_rt(int, siginfo_t*, void*);

126 #endif


127 #define min(a,b) ((a) < (b) ? (a) : (b))

128 #define max(a,b) ((a) > (b) ? (a) : (b))

129 #ifndef HAVE_TIMESPEC_STRUCT

130 struct timespec {

131  time_t tv_sec; /* секунды */

132  long tv_nsec; /* и наносекунды */

133 };

134 #endif


135 /*

136 В функциях-обертках open(), mq_open(), sem_open() мы обрабатываем

137 дополнительные аргументы с помощью макросов va_XXX().

138 Один из аргументов имеет тип mode_t, что приводит

139 к ошибке в BSD/OS, где для этого типа используются

140 16-разрядные целые. При вызове обертки

141 компилятор преобразовывает 16-разрядное целое

142 в 32-разрядное. Поэтому и необходимо то.

143 что сделано ниже.

144 */

145 #ifdef __bsdi__

146 #define va_mode_t int

147 #else

148 #define va_mode_t mode_t

149 #endif


150 /* макросы блокировки записей */

151 #define read_lock(fd, offset, whence, len) \

152  lock_reg(fd, F_SETLK, F_RDLCK, offset, whence, len)

153 #define readw_lock(fd, offset, whence, len) \

154  lock_reg(fd, F_SETLKW, F_RDLCK, offset, whence, len)

155 #define write_lock(fd, offset, whence, len) \

156  lock_reg(fd, F_SETLK, F_WRLCK, offset, whence, len)

157 #define writew_lock(fd, offset, whence, len) \

158  lock_reg(fd, F_SETLKW, F_WRLCK, offset, whence, len)

159 #define un_lock(fd, offset, whence, len) \

160  lock_reg(fd, F_SETLK, F_UNLCK, offset, whence, len)

161 #define is_read_lockable(fd, offset, whence, len) \

162  lock_test(fd, F_RDLCK, offset, whence, len)

163 #define is_write_lockable(fd, offset, whence, len) \

164  lock_test(fd. F_WRLCK, offset, whence, len)

B.2. Заголовочный файл config.h

Перейти на страницу:

Все книги серии Мастер-класс

Секреты резьбы по дереву
Секреты резьбы по дереву

Изделия из древесины и материалов, имитирующих ее текстуру, привычным образом окружают нас в повседневной жизни, поэтому мы относимся к ней как к чему-то обыденному. Но как только ее коснется умелая рука мастера резьбы по дереву, рождается произведение искусства и раскрываются такие качества древесины, как богатая фактура, разнообразие цветов, особая теплота. Эта книга поможет читателю открыть для себя удивительный мир творчества и познать секреты резьбы по дереву. Автор надеется, что начинающие резчики найдут в ней интересный и полезный материал, который позволит им стать мастерами. В приложении представлены рисунки орнаментов и различных узоров, которые на первых порах можно копировать, а по мере приобретения навыка на их основе разрабатывать свои образцы.

Галина Алексеевна Серикова

Сделай сам / Хобби и ремесла / Руководства / Дом и досуг / Словари и Энциклопедии

Похожие книги

C++ Primer Plus
C++ Primer Plus

C++ Primer Plus is a carefully crafted, complete tutorial on one of the most significant and widely used programming languages today. An accessible and easy-to-use self-study guide, this book is appropriate for both serious students of programming as well as developers already proficient in other languages.The sixth edition of C++ Primer Plus has been updated and expanded to cover the latest developments in C++, including a detailed look at the new C++11 standard.Author and educator Stephen Prata has created an introduction to C++ that is instructive, clear, and insightful. Fundamental programming concepts are explained along with details of the C++ language. Many short, practical examples illustrate just one or two concepts at a time, encouraging readers to master new topics by immediately putting them to use.Review questions and programming exercises at the end of each chapter help readers zero in on the most critical information and digest the most difficult concepts.In C++ Primer Plus, you'll find depth, breadth, and a variety of teaching techniques and tools to enhance your learning:• A new detailed chapter on the changes and additional capabilities introduced in the C++11 standard• Complete, integrated discussion of both basic C language and additional C++ features• Clear guidance about when and why to use a feature• Hands-on learning with concise and simple examples that develop your understanding a concept or two at a time• Hundreds of practical sample programs• Review questions and programming exercises at the end of each chapter to test your understanding• Coverage of generic C++ gives you the greatest possible flexibility• Teaches the ISO standard, including discussions of templates, the Standard Template Library, the string class, exceptions, RTTI, and namespaces

Стивен Прата

Программирование, программы, базы данных
Programming with POSIX® Threads
Programming with POSIX® Threads

With this practical book, you will attain a solid understanding of threads and will discover how to put this powerful mode of programming to work in real-world applications. The primary advantage of threaded programming is that it enables your applications to accomplish more than one task at the same time by using the number-crunching power of multiprocessor parallelism and by automatically exploiting I/O concurrency in your code, even on a single processor machine. The result: applications that are faster, more responsive to users, and often easier to maintain. Threaded programming is particularly well suited to network programming where it helps alleviate the bottleneck of slow network I/O. This book offers an in-depth description of the IEEE operating system interface standard, POSIX (Portable Operating System Interface) threads, commonly called Pthreads. Written for experienced C programmers, but assuming no previous knowledge of threads, the book explains basic concepts such as asynchronous programming, the lifecycle of a thread, and synchronization. You then move to more advanced topics such as attributes objects, thread-specific data, and realtime scheduling. An entire chapter is devoted to "real code," with a look at barriers, read/write locks, the work queue manager, and how to utilize existing libraries. In addition, the book tackles one of the thorniest problems faced by thread programmers-debugging-with valuable suggestions on how to avoid code errors and performance problems from the outset. Numerous annotated examples are used to illustrate real-world concepts. A Pthreads mini-reference and a look at future standardization are also included.

David Butenhof

Программирование, программы, базы данных
Adobe InDesign CS3
Adobe InDesign CS3

Книга посвящена верстке и макетированию в программе Adobe InDesign CS3. Помимо того что в ней описываются возможности программы, рассматриваются также принципы и традиции верстки, приводятся примеры решения типичных задач. Все это позволит читателю не только овладеть богатым инструментарием программы, но и грамотно применять его.Материал книги разделен на логические части: теоретические сведения, инструментарий программы, решение задач, – а также рассчитан на два уровня подготовки читателей – начинающих и опытных пользователей, что выгодно отличает книгу от других изданий. Это позволит применять ее как новичкам для знакомства с программой, так и пользователям со стажем для пополнения своих знаний.

Владимир Гавриилович Завгородний , Владимир Завгородний

Программирование, программы, базы данных / Программное обеспечение / Книги по IT
3ds Max 2008
3ds Max 2008

Одни уверены, что нет лучшего способа обучения 3ds Мах, чем прочитать хорошую книгу. Другие склоняются к тому, что эффективнее учиться у преподавателя, который показывает, что и как нужно делать. Данное издание объединяет оба подхода. Его цель – сделать освоение 3ds Мах 2008 максимально быстрым и результативным. Часто после изучения книги у читателя возникают вопросы, почему не получился тот или иной пример. Видеокурс – это гарантия, что такие вопросы не возникнут: ведь автор не только рассказывает, но и показывает, как нужно работать в 3ds Мах.В отличие от большинства интерактивных курсов, где работа в 3ds Мах иллюстрируется на кубиках-шариках, данный видеокурс полностью практический. Все приемы работы с инструментами 3ds Мах 2008 показаны на конкретных примерах, благодаря чему после просмотра курса читатель сможет самостоятельно выполнять даже сложные проекты.

Владимир Антонович Верстак , Владимир Верстак

Программирование, программы, базы данных / Программное обеспечение / Книги по IT