HP C/aC++ for PA-RISC Software manual

Page 4

+wendian

This option enables diagnostics that identify areas in the source code that might have porting issues between little-endian and big-endian. For example

de-reference which could cause endian-dependent behavior

Union definition that is endian dependent

Example

$ cat endian.c union u1 {

char c[4]; int v;

};

$ cc -c +wendian endian.c

"endian.c", line 1: warning #4289-D: endian porting: the definition of the union may be endian dependent

union u1 {

^

+wlock

This option detects multi-threaded programming issues and enables diagnostics for potential errors in using lock/unlock calls in multi-threaded programs that use the pthread library. This is based on cross-module analysis performed by the compiler, which is much more powerful compared to simple scanning and parsing tools. The +wlock option implicitly enables a limited form of cross-module analysis even if -ipoor +O4 options are not specified. This may lead to a significant increase in the compile time in comparison to a build without the +wlock option. Using this option may result in the compiler invoking optimizations other than those which are part of the specified optimization level. If +wlock is used with -ipoor +O4 option, the generated code is not affected and the compile time does not increase much.

The problems detected by +wlock diagnostics include

acquiring an already acquired lock

releasing an already released lock

unconditionally releasing a conditionally acquired lock

Example

$ cat lock.c #include <pthread.h> #include <stdio.h>

int a;

pthread_mutex_t Mutex;

void perform_operation(pthread_mutex_t* mutex1, int increment, int* global) {

if (increment > 10){

int status = pthread_mutex_lock(mutex1);

}

*global = *global + increment;

int status = pthread_mutex_unlock(&Mutex);

}

int main(void) { int i; scanf("%d", &i);

perform_operation(&Mutex, i, &a); printf("%d is value\n", a);

}

$ cc +wlock lock.c

4

Image 4
Contents Page Introduction Compile Time DiagnosticsWhat’s New Example Page Security Diagnostics Example of unsafe loop exit condition Customization of Compiler Diagnostics Runtime Checking +Olit=none option Page Page Executable name.pid.threads Ch = intval & 0xff Execution Path Recovery Further information
Related manuals
Manual 230 pages 50.97 Kb