summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PACE/ChangeLog36
-rw-r--r--PACE/include/makeinclude/rules.common.GNU1
-rw-r--r--PACE/tests/Makefile9
-rw-r--r--PACE/tests/mqueue_test.c139
4 files changed, 139 insertions, 46 deletions
diff --git a/PACE/ChangeLog b/PACE/ChangeLog
index fa114b19150..e14eb65acd4 100644
--- a/PACE/ChangeLog
+++ b/PACE/ChangeLog
@@ -1,3 +1,39 @@
+Thu Jul 13 00:46:37 2000 John Heitmann <jwh1@cs.wustl.edu>
+
+ * pace/signal.h
+ * pace/posix/signal.h
+ * pace/posix/signal.inl
+
+ Changed the typedef of pace_s_sigevent
+ to pace_sigevent_s to match up with pace_stat_s. The
+ problem with both of these is that the data type names
+ conflict with function names.
+
+ * pace/stdio.h
+ * pace/posix/stdio.c
+
+ Changed all '...' functions to defines. Now the library
+ should be totally empty on platforms without emulation code.
+
+ * include/makeinclude/rules.common.GNU
+ * tests/Makefile
+
+ Because the library can be empty again, don't include
+ the library by default. As a temporary kludge emulation=1
+ is set in rules.common.GNU for Linux, which is the only
+ platform thus far which has a non-empty library.
+
+ * pace/emulation/mqueue.c
+ * pace/emulation/mqueue.h
+
+ Support for all functionality is now complete, cleaner,
+ and somewhat less buggy.
+
+ * tests/mqueue_test.c
+
+ Borrowed a test from Konstantin Knizhnik's web site,
+ will eventually have to make this a one-button test.
+
Wed Jul 12 17:30:54 2000 John Heitmann <jwh1@cs.wustl.edu>
* pace/posix/types.h
diff --git a/PACE/include/makeinclude/rules.common.GNU b/PACE/include/makeinclude/rules.common.GNU
index 88602d97a81..24bf09d38e5 100644
--- a/PACE/include/makeinclude/rules.common.GNU
+++ b/PACE/include/makeinclude/rules.common.GNU
@@ -75,5 +75,6 @@ endif
ifeq ($(PACE_SYSNAME),Linux)
VPATH :=.:posix:$(VPATH)
+ emulation=1
CFLAGS += -DPACE_LINUX=$(PACE_SYSVER)
endif
diff --git a/PACE/tests/Makefile b/PACE/tests/Makefile
index 85bc9796392..bfe7f13371b 100644
--- a/PACE/tests/Makefile
+++ b/PACE/tests/Makefile
@@ -14,7 +14,7 @@ endif # static_libs_only
# If we are inlining the PACE functions then we don't want to include
# the PACE library (and we need to define PACE_HAS_INLINE). If we're not
# inlining then we need to include the PACE library. Inlining is the default.
-LIBS += -L$(PACE_ROOT)/pace -lPACE
+
ifndef inline
CFLAGS += -DPACE_HAS_INLINE
else
@@ -23,8 +23,6 @@ else
endif # inline
endif # ! inline
-LIBS += -L$(PACE_ROOT)/pace -lPACE
-
#----------------------------------------------------------------------------
# Local macros
#----------------------------------------------------------------------------
@@ -59,6 +57,11 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
include $(ACE_ROOT)/PACE/include/makeinclude/rules.common.GNU
+# To compile in the PACE lib on platforms that compile c code
+ifeq (1, $(emulation))
+ LIBS += -L$(PACE_ROOT)/pace -lPACE
+endif # emulation
+
# To build multiple executables in the same directory on AIX, it works
# best to wipe out any previously-created tempinc directory.
# The compiler/linker isn't too smart about instantiating templates...
diff --git a/PACE/tests/mqueue_test.c b/PACE/tests/mqueue_test.c
index ee15cd78222..1a198c61524 100644
--- a/PACE/tests/mqueue_test.c
+++ b/PACE/tests/mqueue_test.c
@@ -2,61 +2,114 @@
#include "pace/fcntl.h"
#include "pace/mqueue.h"
#include "pace/stdlib.h"
+#include "pace/signal.h"
+#include "pace/string.h"
-int main (int argc, char** argv)
-{
- char* m1 = "Message1\n ";
- int s1 = 10;
- char* m2 = "Message 2\n ";
- int s2 = 11;
- pace_mqd_t mqd;
- pace_mq_attr attr;
- int flags = O_RDWR | O_CREAT;
-
- attr.mq_flags = O_NONBLOCK;
- attr.mq_msgsize = 51;
- attr.mq_maxmsg = 50;
- mqd = pace_mq_open ("/hello3", flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, &attr);
- if ((int)mqd == -1)
- {
- perror ("Open");
- return -1;
- }
+/* Most of this code is borowed from Konstantin Knizhnik <http://www.ispras.ru/~knizhnik/posix1b/> */
- PACE_UNUSED_ARG (argc);
- PACE_UNUSED_ARG (argv);
-
- printf ("Sending Message 1\n");
+pace_mqd_t mqdes;
- if (pace_mq_send (mqd, m1, s1, s1) == -1)
+void msg_handler()
+{
+ char buf[1024];
+ unsigned int priority;
+ int len = pace_mq_receive(mqdes, buf, sizeof buf, &priority);
+ if (len < 0)
{
- perror ("send");
- return -1;
+ perror("mq_receive");
}
+ pace_printf("\nReceive message with priority %d: %s\n", priority, buf);
+}
- printf ("Sending Message 2\n");
+#define QUEUE_NAME "/testmsg1"
+int main (int argc, char** argv)
+{
+# if !(PACE_LYNXOS)
+ char buf[1024];
+ int choice, len;
+ unsigned int priority;
+ pace_sigevent notification;
+ static pace_sigaction_s sa;
+ int one = 1;
- if (pace_mq_send (mqd, m2, s2, s2) == -1)
+ mqdes = pace_mq_open(QUEUE_NAME, O_CREAT | O_RDWR, 0777, 0);
+ if (mqdes == (pace_mqd_t)-1)
{
- perror ("send");
- return -1;
+ perror("mq_open");
+ return 1;
}
- m1 = malloc (60);
- m2 = malloc (60);
+ notification.sigev_notify = SIGEV_SIGNAL;
+ notification.sigev_signo = SIGUSR1;
- if (pace_mq_receive (mqd, m1, 60, 0) == -1)
- {
- perror ("receive");
- return -1;
- }
- printf (m1);
- if (pace_mq_receive (mqd, m2, 60, 0) == -1)
+ sa.sa_handler = msg_handler;
+ sa.sa_flags = SA_RESTART;
+ pace_sigaction(SIGUSR1, &sa, NULL);
+
+ while (one)
{
- perror ("receive");
- return -1;
+ printf("\t1. Send\n"
+ "\t2. Asynchronouse receive\n"
+ "\t3. Synchronouse receive\n"
+ "\t4. Close queue and exit\n"
+ "\t5. Remove queue and exit\n"
+ "> ");
+ if (!pace_fgets(buf, sizeof buf, stdin))
+ {
+ return 1;
+ }
+ if (pace_sscanf(buf, "%d", &choice) != 1)
+ {
+ pace_printf("Please select 1..5\n");
+ continue;
+ }
+ switch (choice)
+ {
+ case 1:
+ do
+ {
+ pace_printf("Message priority: ");
+ pace_fgets(buf, sizeof buf, stdin);
+ } while (pace_sscanf(buf, "%d", &priority) != 1);
+ pace_printf("Message to send: ");
+ pace_fgets(buf, sizeof buf, stdin);
+ if (pace_mq_send(mqdes, buf, pace_strlen(buf)+1, priority) == -1)
+ {
+ perror("mq_send");
+ return 1;
+ }
+ break;
+ case 2:
+ pace_mq_notify(mqdes, &notification);
+ pace_printf("Waiting for notifications...\n");
+ break;
+ case 3:
+ len = pace_mq_receive(mqdes, buf, sizeof buf, &priority);
+ if (len < 0)
+ {
+ perror("mq_receive");
+ }
+ pace_printf("Receive message with priority %d: %s\n", priority, buf);
+ break;
+ case 4:
+ pace_mq_close(mqdes);
+ return 0;
+ case 5:
+ pace_mq_close(mqdes);
+ pace_mq_unlink(QUEUE_NAME);
+ return 0;
+ default:
+ pace_printf("Please select 1..5\n");
+ }
}
- printf (m2);
- exit (EXIT_SUCCESS);
+ PACE_UNUSED_ARG (argc);
+ PACE_UNUSED_ARG (argv);
+ return (EXIT_SUCCESS);
+#else
+ pace_printf ("No errors, have occurred. On the other hand no operations have been performed either. Take what you can get I guess.\n");
+ PACE_UNUSED_ARG (argc);
+ PACE_UNUSED_ARG (argv);
+ return (EXIT_SUCCESS);
+#endif LYNXOS
}