summaryrefslogtreecommitdiff
path: root/posix_api/psx_mqueue_report
diff options
context:
space:
mode:
Diffstat (limited to 'posix_api/psx_mqueue_report')
-rw-r--r--posix_api/psx_mqueue_report/Makefile20
-rw-r--r--posix_api/psx_mqueue_report/mqueue_attr_report.c48
-rw-r--r--posix_api/psx_mqueue_report/rtems_config.c48
-rw-r--r--posix_api/psx_mqueue_report/wscript15
4 files changed, 131 insertions, 0 deletions
diff --git a/posix_api/psx_mqueue_report/Makefile b/posix_api/psx_mqueue_report/Makefile
new file mode 100644
index 0000000..52027fd
--- /dev/null
+++ b/posix_api/psx_mqueue_report/Makefile
@@ -0,0 +1,20 @@
+#
+# RTEMS_MAKEFILE_PATH is typically set in an environment variable
+#
+
+PGM=${ARCH}/psx_mqueue_report.exe
+
+# C source names
+CSRCS = mqueue_attr_report.c rtems_config.c
+COBJS = $(CSRCS:%.c=${ARCH}/%.o)
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS)
+
+all: ${ARCH} $(PGM)
+
+$(PGM): $(OBJS)
+ $(make-exe)
diff --git a/posix_api/psx_mqueue_report/mqueue_attr_report.c b/posix_api/psx_mqueue_report/mqueue_attr_report.c
new file mode 100644
index 0000000..855330c
--- /dev/null
+++ b/posix_api/psx_mqueue_report/mqueue_attr_report.c
@@ -0,0 +1,48 @@
+/*
+ * Program to print default POSIX message queue attributes
+ */
+
+/*
+ * Copyright 2018 Joel Sherrill (joel@rtems.org)
+ *
+ * This file's license is 2-clause BSD as in this distribution's LICENSE.2 file.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include <fcntl.h> /* For O_* constants */
+#include <sys/stat.h>
+#include <mqueue.h>
+
+static void print_attr(mqd_t mqd)
+{
+ int rc;
+ struct mq_attr attr;
+
+ rc = mq_getattr( mqd, &attr );
+ assert( rc == 0 );
+
+ printf( "mq_maxmsg: %ld\n", attr.mq_maxmsg );
+ printf( "mq_msgsize: %ld\n", attr.mq_msgsize );
+}
+
+int main()
+{
+ mqd_t mqd;
+
+ puts( "*** POSIX Message Queue Default Attributes Report ***" );
+
+ mqd = mq_open( "/testq", O_CREAT|O_RDWR, 0777, NULL );
+ if ( mqd == (mqd_t) -1 ) {
+ perror("mq_open" );
+ }
+ assert( mqd != (mqd_t) -1 );
+
+ print_attr( mqd );
+
+ puts( "*** END OF POSIX Message Queue Default Attributes Report ***" );
+ exit( 0 );
+}
diff --git a/posix_api/psx_mqueue_report/rtems_config.c b/posix_api/psx_mqueue_report/rtems_config.c
new file mode 100644
index 0000000..fd0a0f8
--- /dev/null
+++ b/posix_api/psx_mqueue_report/rtems_config.c
@@ -0,0 +1,48 @@
+/*
+ * This file contains the RTEMS Configuration for this example.
+ */
+
+/*
+ * Copyright 2018 Joel Sherrill (joel@rtems.org)
+ *
+ * This file's license is 2-clause BSD as in this distribution's LICENSE.2 file.
+ */
+
+#include <stdlib.h>
+
+int main(int argc, char **argv);
+
+static char *argv_list[] = {
+ "report",
+ ""
+};
+static void *POSIX_Init(void *arg)
+{
+ (void) arg; /* deliberately ignored */
+
+ /*
+ * Initialize optional services
+ */
+
+ /*
+ * Could get arguments from command line or have a static set.
+ */
+ (void) main(1, argv_list);
+
+ return NULL;
+}
+
+#include <bsp.h> /* for device driver prototypes */
+
+/* NOTICE: the clock driver is explicitly disabled */
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_UNLIMITED_OBJECTS
+#define CONFIGURE_UNIFIED_WORK_AREAS
+#define CONFIGURE_MINIMUM_TASK_STACK_SIZE (64 * 1024)
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
diff --git a/posix_api/psx_mqueue_report/wscript b/posix_api/psx_mqueue_report/wscript
new file mode 100644
index 0000000..fed2355
--- /dev/null
+++ b/posix_api/psx_mqueue_report/wscript
@@ -0,0 +1,15 @@
+# Copyright 2013 Gedare Bloom (gedare@rtems.org)
+#
+# This file's license is 2-clause BSD as in this distribution's LICENSE.2 file.
+#
+
+import rtems_waf.rtems as rtems
+
+def build(bld):
+ rtems.build(bld)
+
+ bld(features = 'c cprogram',
+ target = 'psx_mqueue_report.exe',
+ source = ['mqueue_attr_report.c','rtems_config.c'],
+ lib = ['c'])
+