issue #115 over at travitch's place.

This commit is contained in:
Ian A.Mason
2021-07-28 13:34:20 -07:00
parent 803ee8258d
commit 001b853549
5 changed files with 62 additions and 2 deletions
+3 -1
View File
@@ -19,7 +19,7 @@ e:
one:
${CC} foo.c bar.c baz.c main.c -o main
${CC} -pthread foo.c bar.c baz.c main.c -o main
two:
${CC} foo.c bar.c baz.c main.c -c
@@ -37,6 +37,8 @@ mix_e:
${CC} -emit-llvm foo.c bar.c -c
${CC} foo.bc bar.bc baz.c main.c -o main
threads:
${CXX} -pthread test1.cpp test2.cpp -o main
objects:
${CC} foo.c -c
+14
View File
@@ -0,0 +1,14 @@
// test1.cpp
#include "test1.h"
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
int glb_ext = 1;
void lock() {
pthread_mutex_lock(&m);
}
void unlock() {
pthread_mutex_unlock(&m);
}
+14
View File
@@ -0,0 +1,14 @@
// test1.h
#ifndef TEST1_H_
#define TEST1_H_
#include <pthread.h>
#include <stdio.h>
extern int glb_ext;
extern pthread_mutex_t m;
void lock();
void unlock();
#endif
+29
View File
@@ -0,0 +1,29 @@
// test2.cpp
#include "test1.h"
using namespace std;
int glb_test;
void *Thread1(void* x) {
lock();
glb_test++;
unlock();
return nullptr;
}
void *Thread2(void* x) {
lock();
glb_test++;
unlock();
return nullptr;
}
int main() {
pthread_t t[2];
pthread_create(&t[0], nullptr, Thread1, nullptr);
pthread_create(&t[1], nullptr, Thread1, nullptr);
pthread_join(t[0], nullptr);
pthread_join(t[1], nullptr);
return 0;
}
+2 -1
View File
@@ -63,7 +63,8 @@ class ArgumentListFilter:
'-no-integrated-as' : (0, ArgumentListFilter.compileUnaryCallback),
'-integrated-as' : (0, ArgumentListFilter.compileUnaryCallback),
#iam: gcc uses this in both compile and link, but clang only in compile
'-pthread' : (0, ArgumentListFilter.compileUnaryCallback),
#iam: actually on linux it looks to be both
'-pthread' : (0, ArgumentListFilter.compileLinkUnaryCallback),
# I think this is a compiler search path flag. It is
# clang only, so I don't think it counts as a separate CPP
# flag. Android uses this flag with its clang builds.