The idea of the patch is "to make things that should be extern, extern". The means to do this are:
1. Explicitly declaring variables extern in some places.
2. Defining _USC_LIB_ where appropriate.
My understanding of _USC_LIB_ define is that it exists so the usctest.h header can be included in a lib or non-test source file where you want to use extern declarations of TEST_RETURN, TEST_ERRNO etc. to avoid having a copy of the variable in your library and a copy of the variable in your test. I've added -D_USC_LIB_ to the CFLAGS of library code where necessary, by, Will Newton <will.newton@gmail.com>
diff --git a/testcases/kernel/mem/hugetlb/lib/Makefile b/testcases/kernel/mem/hugetlb/lib/Makefile
index b81cd30..eafa10b 100644
--- a/testcases/kernel/mem/hugetlb/lib/Makefile
+++ b/testcases/kernel/mem/hugetlb/lib/Makefile
@@ -25,6 +25,7 @@
OBJS=$(SRCS:.c=.o)
MAINS=libipc.a
CFLAGS+=-I../../../../../include -g -Wall
+CFLAGS+=-D_USC_LIB_
all: libipc.a
diff --git a/testcases/kernel/syscalls/ipc/lib/Makefile b/testcases/kernel/syscalls/ipc/lib/Makefile
index b573e71..952665d 100644
--- a/testcases/kernel/syscalls/ipc/lib/Makefile
+++ b/testcases/kernel/syscalls/ipc/lib/Makefile
@@ -22,6 +22,7 @@
LIBIPC_HEADERS = ipcmsg.h ipcsem.h
CFLAGS += -I../../../../../include -Wall
+CFLAGS += -D_USC_LIB_
all: $(LIBIPC)
diff --git a/testcases/kernel/syscalls/ipc/lib/ipcmsg.h b/testcases/kernel/syscalls/ipc/lib/ipcmsg.h
index e8e28ef..52589d9 100644
--- a/testcases/kernel/syscalls/ipc/lib/ipcmsg.h
+++ b/testcases/kernel/syscalls/ipc/lib/ipcmsg.h
@@ -50,7 +50,7 @@
char mtext[MSGSIZE + 1]; /* add 1 here so the message can be 1024 */
} MSGBUF; /* characters long with a '\0' termination */
-#if (!defined CONFIG_COLDFIRE || defined LIBIPC)
+#ifdef LIBIPC
key_t msgkey; /* the ftok() generated message key */
#else
extern key_t msgkey; /* the ftok() generated message key */
diff --git a/testcases/kernel/syscalls/ipc/lib/ipcsem.h b/testcases/kernel/syscalls/ipc/lib/ipcsem.h
index f4fbbf6..27d65e7 100644
--- a/testcases/kernel/syscalls/ipc/lib/ipcsem.h
+++ b/testcases/kernel/syscalls/ipc/lib/ipcsem.h
@@ -42,7 +42,7 @@
#define PSEMS 10 /* a reasonable value for the number of */
/* "primitive semaphores" per ID */
-#if (!defined CONFIG_COLDFIRE || defined LIBIPC)
+#ifdef LIBIPC
key_t semkey; /* an IPC key generated by ftok() */
#else
extern key_t semkey; /* an IPC key generated by ftok() */
diff --git a/testcases/kernel/syscalls/kill/kill05.c b/testcases/kernel/syscalls/kill/kill05.c
index cc75e05..b3b933b 100644
--- a/testcases/kernel/syscalls/kill/kill05.c
+++ b/testcases/kernel/syscalls/kill/kill05.c
@@ -89,7 +89,7 @@
char *TCID= "kill05";
int TST_TOTAL = 1;
int shmid1 = -1;
-key_t semkey;
+extern key_t semkey;
int *flag;
int exp_enos[] = {EPERM, 0};
diff --git a/testcases/kernel/syscalls/kill/kill07.c b/testcases/kernel/syscalls/kill/kill07.c
index f73194e..a386fcd 100644
--- a/testcases/kernel/syscalls/kill/kill07.c
+++ b/testcases/kernel/syscalls/kill/kill07.c
@@ -76,11 +76,7 @@
char *TCID= "kill07";
int TST_TOTAL = 1;
int shmid1;
-#ifndef CONFIG_COLDFIRE
-key_t semkey;
-#else
extern key_t semkey;
-#endif
int *flag;
extern int Tst_count;
diff --git a/testcases/kernel/syscalls/lib/Makefile b/testcases/kernel/syscalls/lib/Makefile
index db21d2f..bfce596 100644
--- a/testcases/kernel/syscalls/lib/Makefile
+++ b/testcases/kernel/syscalls/lib/Makefile
@@ -18,6 +18,7 @@
DIR=lib
CFLAGS += -I../../../../include -Wall
+CFLAGS += -D_USC_LIB_
SRC=libtestsuite.c
OBJS=$(SRC:.c=.o)
MAINS=../libtestsuite.a
diff --git a/testcases/kernel/syscalls/nftw/lib.c b/testcases/kernel/syscalls/nftw/lib.c
index cedcac2..241f27e 100644
--- a/testcases/kernel/syscalls/nftw/lib.c
+++ b/testcases/kernel/syscalls/nftw/lib.c
@@ -25,6 +25,7 @@
* lib.c - This file contains code for common failure conditions
*/
+#define _USC_LIB_
#include "nftw.h"
diff --git a/testcases/network/sctp/testlib/Makefile b/testcases/network/sctp/testlib/Makefile
index eea491e..2f00fa6 100644
--- a/testcases/network/sctp/testlib/Makefile
+++ b/testcases/network/sctp/testlib/Makefile
@@ -24,7 +24,7 @@
INCLUDES+=-I../../../../include -I../include -I.
LIBS+=-L../../../../lib -L../lib
-CFLAGS += -g $(INCLUDES) -DLTP
+CFLAGS += -g $(INCLUDES) -DLTP -D_USC_LIB_
LOADLIBES += $(LIBS) -lltp -lsctp
SRCS=sctputil.c
OBJS=$(SRCS:.c=.o)