Re: [PATCH v2] Testsuite of inttypes methods.

2017-09-05 Thread Joel Sherrill
Unless I am doing something wrong, this is a diff to code which has
not been merged.  Can you send a complete patch with the entire
contents of the psxinttypes01 directory?

Sorry for being slow. It was a long holiday weekend here.

--joel

On Sat, Sep 2, 2017 at 11:45 AM, Aditya Upadhyay 
wrote:

> ---
>  testsuites/psxtests/psxinttypes01/init.c   | 23
> +++---
>  .../psxtests/psxinttypes01/psxinttypes01.scn   |  6 +++---
>  2 files changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/testsuites/psxtests/psxinttypes01/init.c
> b/testsuites/psxtests/psxinttypes01/init.c
> index e593e43..8fc79f6 100644
> --- a/testsuites/psxtests/psxinttypes01/init.c
> +++ b/testsuites/psxtests/psxinttypes01/init.c
> @@ -13,12 +13,13 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  /* forward declarations to avoid warnings */
>
>  rtems_task Init(rtems_task_argument argument);
> -const char rtems_test_name[] = "PSXINTTYPE 01";
> +const char rtems_test_name[] = "PSXINTTYPES 01";
>  rtems_printer rtems_test_printer;
>
>  /*
> @@ -48,16 +49,16 @@ rtems_task Init(
>/* Test for wcstoimax */
>
>m = wcstoimax(nptr1, &endptr1, base);
> -  rtems_test_assert (m == ERANGE);
> -  rtems_test_assert (m == EINVAL);
> -
> +  rtems_test_assert (m != 0);
> +  rtems_test_assert (!(*endptr1));
> +
>printf( "wcstoimax = %jd\n", m );
>
>/* test for strtoumax */
>
>j = strtoumax (nptr, &endptr, base);
> -  rtems_test_assert (j == ERANGE);
> -  rtems_test_assert (j == EINVAL);
> +  rtems_test_assert (j != 0);
> +  rtems_test_assert (*endptr);
>
>printf( "strtoumax = %ju ( base %d )\n", j, base );
>printf( "Stopped scan at %s\n\n", endptr );
> @@ -65,8 +66,8 @@ rtems_task Init(
>/*test for wcstoumax */
>
>k = wcstoumax (nptr1, &endptr1, base);
> -  rtems_test_assert (k == ERANGE);
> -  rtems_test_assert (k == EINVAL);
> +  rtems_test_assert (k != 0);
> +  rtems_test_assert (!(*endptr1));
>
>printf( "wcstoumax = %ju\n", k );
>
> @@ -81,9 +82,9 @@ rtems_task Init(
>
>/*Test for strtoimax */
>
> -  n = strtoimax ("", &endptr, 2);
> -  rtems_test_assert (n == ERANGE);
> -  rtems_test_assert (n == EINVAL);
> +  n = strtoimax ("-123junk", &endptr, base);
> +  rtems_test_assert (n != 0);
> +  rtems_test_assert (*endptr);
>
>printf( "strtoimax value = %jd\n", n);
>
> diff --git a/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
> b/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
> index 47a5416..79553be 100644
> --- a/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
> +++ b/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
> @@ -1,4 +1,4 @@
> -*** BEGIN OF TEST PSXINTTYPE 01 ***
> +*** BEGIN OF TEST PSXINTTYPES 01 ***
>  wcstoimax = 10110134932
>  strtoumax = 20690239864 ( base 10 )
>  Stopped scan at abc
> @@ -6,6 +6,6 @@ Stopped scan at abc
>  wcstoumax = 10110134932
>  imax div value = 3
>  imaxabs_value = 1234
> -strtoimax value = 255
> -*** END OF TEST PSXINTTYPE 01 ***
> +strtoimax value = -123
> +*** END OF TEST PSXINTTYPES 01 ***
>
> --
> 2.7.4
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: x86 get TLS method

2017-09-05 Thread Sebastian Huber

On 28/08/17 17:26, Joel Sherrill wrote:


My question is what's the generic way to get the TLS area for a
thread? Is the ARM method in C specific to the ARM or generic?


See

https://www.akkadia.org/drepper/tls.pdf

there are some variants.

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: How to align ARM BSP .data section on 4K boundary

2017-09-05 Thread Sebastian Huber

On 26/08/17 23:31, Joel Sherrill wrote:


Hi

Using the shared linkcmds, what's the magic to get .data on a 4K boundary?


Maybe you can add a empty array with a 4KiB alignment attribute.

If you want to place all read-write data on a 4KiB boundary, then use

bsp_section_rwbarrier_align = 4096;

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH] libio: Remove special-case reference count

2017-09-05 Thread Sebastian Huber
The top-level IO library structures should contain no special-case data.

Update #2859.
---
 cpukit/libcsupport/include/rtems/libio.h|  1 -
 cpukit/libcsupport/include/rtems/libio_.h   | 41 -
 cpukit/libcsupport/src/libio.c  | 32 ++
 cpukit/posix/include/rtems/posix/mmanimpl.h | 12 -
 cpukit/posix/src/mmap.c | 24 -
 cpukit/posix/src/munmap.c   | 29 ++--
 6 files changed, 27 insertions(+), 112 deletions(-)

diff --git a/cpukit/libcsupport/include/rtems/libio.h 
b/cpukit/libcsupport/include/rtems/libio.h
index 8226d18ba2..7022de671c 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -1320,7 +1320,6 @@ struct rtems_libio_tt {
   rtems_driver_name_t*driver;
   off_t   offset;/* current offset into 
file */
   uint32_tflags;
-  uint32_tmapping_refcnt; /* current mappings 
*/
   rtems_filesystem_location_info_tpathinfo;
   uint32_tdata0; /* private to "driver" */
   void   *data1; /* ... */
diff --git a/cpukit/libcsupport/include/rtems/libio_.h 
b/cpukit/libcsupport/include/rtems/libio_.h
index 695a4c45a5..c2fb975bf7 100644
--- a/cpukit/libcsupport/include/rtems/libio_.h
+++ b/cpukit/libcsupport/include/rtems/libio_.h
@@ -304,47 +304,6 @@ void rtems_libio_free(
   rtems_libio_t *iop
 );
 
-/**
- * Garbage collects the free libio in case it was previously freed but there
- * were still references to it.
- */
-void rtems_libio_check_deferred_free( rtems_libio_t *iop );
-
-/**
- * Increment the reference count tracking number of mmap mappings of a file.
- * Returns the updated reference count value.
- */
-static inline uint32_t rtems_libio_increment_mapping_refcnt(rtems_libio_t *iop)
-{
-  uint32_t refcnt;
-  rtems_libio_lock();
-  refcnt = ++iop->mapping_refcnt;
-  rtems_libio_unlock();
-  return refcnt;
-}
-
-/**
- * Decrement the reference count tracking number of mmap mappings of a file.
- * Returns the updated reference count value.
- */
-static inline uint32_t rtems_libio_decrement_mapping_refcnt(rtems_libio_t *iop)
-{
-  uint32_t refcnt;
-  rtems_libio_lock();
-  refcnt = --iop->mapping_refcnt;
-  rtems_libio_unlock();
-  return refcnt;
-}
-
-static inline bool rtems_libio_is_mapped(rtems_libio_t *iop)
-{
-  bool is_mapped;
-  rtems_libio_lock();
-  is_mapped = iop->mapping_refcnt != 0;
-  rtems_libio_unlock();
-  return is_mapped;
-}
-
 /*
  *  File System Routine Prototypes
  */
diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c
index e89634f090..22be6411a2 100644
--- a/cpukit/libcsupport/src/libio.c
+++ b/cpukit/libcsupport/src/libio.c
@@ -138,36 +138,8 @@ void rtems_libio_free(
   rtems_libio_lock();
 
 iop->flags = 0;
-/* If the mapping_refcnt is non-zero, the deferred free will be
- * called by munmap. The iop is no longer good to use, but it cannot
- * be recycled until the mapped file is unmapped. deferred free knows
- * it can recycle the iop in case flags == 0 and iop->data1 == iop,
- * since these two conditions are not otherwise satisifed at
- * the same time. It may be possible that iop->data1 == iop when
- * flags != 0 because data1 is private to the driver. However, flags == 0
- * means a freed iop, and an iop on the freelist cannot store a pointer
- * to itself in data1, or else the freelist is corrupted. We can't use
- * NULL in data1 as an indicator because it is used by the tail of the
- * freelist. */
-if ( iop->mapping_refcnt == 0 ) {
-  iop->data1 = rtems_libio_iop_freelist;
-  rtems_libio_iop_freelist = iop;
-} else {
-  iop->data1 = iop;
-}
+iop->data1 = rtems_libio_iop_freelist;
+rtems_libio_iop_freelist = iop;
 
   rtems_libio_unlock();
 }
-
-void rtems_libio_check_deferred_free(
-  rtems_libio_t *iop
-)
-{
-  rtems_libio_lock();
-if ( iop->mapping_refcnt == 0 && iop->flags == 0 && iop->data1 == iop) {
-  /* No mappings and rtems_libio_free already called, recycle the iop */
-  iop->data1 = rtems_libio_iop_freelist;
-  rtems_libio_iop_freelist = iop;
-}
-  rtems_libio_unlock();
-}
diff --git a/cpukit/posix/include/rtems/posix/mmanimpl.h 
b/cpukit/posix/include/rtems/posix/mmanimpl.h
index ff59d911ca..e1cc672331 100644
--- a/cpukit/posix/include/rtems/posix/mmanimpl.h
+++ b/cpukit/posix/include/rtems/posix/mmanimpl.h
@@ -18,6 +18,7 @@
 
 #include 
 #include  /* FIXME: use score chains for proper layering? */
+#include 
 
 #ifdef __cplusplus
 extern "C" {
@@ -29,12 +30,11 @@ extern "C" {
  * Every mmap'ed region has a mapping.
  */
 typedef struct mmap_mappings_s {
-  rtems_chain_node node;  /**< The mapping chain's node */
-  void*addr;  /**< The address of the m

[PATCH] Testsuite for inttypes methods.

2017-09-05 Thread Aditya Upadhyay
---
 testsuites/psxtests/psxinttypes01/Makefile.am  |  22 +
 testsuites/psxtests/psxinttypes01/init.c   | 107 +
 .../psxtests/psxinttypes01/psxinttypes01.scn   |  11 +++
 3 files changed, 140 insertions(+)
 create mode 100644 testsuites/psxtests/psxinttypes01/Makefile.am
 create mode 100644 testsuites/psxtests/psxinttypes01/init.c
 create mode 100644 testsuites/psxtests/psxinttypes01/psxinttypes01.scn

diff --git a/testsuites/psxtests/psxinttypes01/Makefile.am 
b/testsuites/psxtests/psxinttypes01/Makefile.am
new file mode 100644
index 000..90608d4
--- /dev/null
+++ b/testsuites/psxtests/psxinttypes01/Makefile.am
@@ -0,0 +1,22 @@
+
+rtems_tests_PROGRAMS = psxinttypes01
+psxinttypes01_SOURCES = init.c
+
+dist_rtems_tests_DATA = psxinttypes01.scn
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+#AM_CPPFLAGS = -I$(top_srcdir)/include
+#AM_CPPFLAGS = -I$(top_srcdir)/../support/include$(psxinttypes01_LDADD)
+
+LINK_OBJS = $(psxinttypes01_OBJECTS) 
+LINK_LIBS = $(psxinttypes01_LDLIBS)  
+
+psxinttypes01$(EXEEXT): $(psxinttypes01_OBJECTS) $(psxinttypes01_DEPENDENCIES)
+   @rm -f psxinttypes01$(EXEEXT)
+   $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxinttypes01/init.c 
b/testsuites/psxtests/psxinttypes01/init.c
new file mode 100644
index 000..43d49f6
--- /dev/null
+++ b/testsuites/psxtests/psxinttypes01/init.c
@@ -0,0 +1,107 @@
+/*
+ *  This is the test for inttypes library. It covers these functions :
+ *  imaxabs(), imaxdiv(), strtoimax(), strtoumax(), wcstoimax(), wcstoumax().
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* forward declarations to avoid warnings */
+
+rtems_task Init(rtems_task_argument argument);
+const char rtems_test_name[] = "PSXINTTYPE 01";
+rtems_printer rtems_test_printer;
+
+/*
+ * RTEMS Startup Task
+ */
+
+rtems_task Init(
+  rtems_task_argument ignored
+)
+{
+  rtems_print_printer_printf(&rtems_test_printer);
+  rtems_test_begin();
+
+  char* endptr, *nptr;
+
+  uintmax_t j, k;
+
+  int base = 10;
+  
+  wchar_t *nptr1, *endptr1;
+
+  intmax_t m, n;
+
+  nptr1 = L"10110134932";
+  nptr  = "20690239864abc";
+
+  /* Test for wcstoimax */
+
+  m = wcstoimax(nptr1, &endptr1, base);
+  rtems_test_assert (m != 0);
+  rtems_test_assert (!(*endptr1));
+  
+  printf( "wcstoimax = %jd\n", m );
+
+  /* test for strtoumax */
+
+  j = strtoumax (nptr, &endptr, base);
+  rtems_test_assert (j != 0);
+  rtems_test_assert (*endptr);
+
+  printf( "strtoumax = %ju ( base %d )\n", j, base );
+  printf( "Stopped scan at %s\n\n", endptr );
+
+  /*test for wcstoumax */
+
+  k = wcstoumax (nptr1, &endptr1, base);
+  rtems_test_assert (k != 0);
+  rtems_test_assert (!(*endptr1));
+
+  printf( "wcstoumax = %ju\n", k );
+
+  /*Test for imaxdiv */
+
+  imaxdiv_t retrival = imaxdiv ( 27, 4 );
+  printf( "imax div value = %jd\n", retrival.rem );
+
+  /*Test for imaxabs  */
+
+  printf( "imaxabs_value = %jd\n", imaxabs (-1234));
+
+  /*Test for strtoimax */
+
+  n = strtoimax ("-123junk", &endptr, base);
+  rtems_test_assert (n != 0);
+  rtems_test_assert (*endptr);
+
+  printf( "strtoimax value = %jd\n", n);
+
+
+  rtems_test_end();
+  exit( 0 );
+}
+
+/* NOTICE: the clock driver is explicitly disabled */
+
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS1
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_INIT
+#include 
diff --git a/testsuites/psxtests/psxinttypes01/psxinttypes01.scn 
b/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
new file mode 100644
index 000..79553be
--- /dev/null
+++ b/testsuites/psxtests/psxinttypes01/psxinttypes01.scn
@@ -0,0 +1,11 @@
+*** BEGIN OF TEST PSXINTTYPES 01 ***
+wcstoimax = 10110134932
+strtoumax = 20690239864 ( base 10 )
+Stopped scan at abc
+
+wcstoumax = 10110134932
+imax div value = 3
+imaxabs_value = 1234
+strtoimax value = -123
+*** END OF TEST PSXINTTYPES 01 ***
+
-- 
2.7.4

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] Implement clock()

2017-09-05 Thread Sebastian Huber
Newlib uses _times_r() in clock().  The problem is that the _times_r()
clock frequency is defined by sysconf(_SC_CLK_TCK).  The clock frequency
of clock() is the constant CLOCKS_PER_SEC.

FreeBSD uses getrusage() for clock().  Since RTEMS has only one process,
the implementation can be simplified.

Update #3121.
---
 cpukit/libcsupport/Makefile.am |  1 +
 cpukit/libcsupport/src/clock.c | 33 +
 2 files changed, 34 insertions(+)
 create mode 100644 cpukit/libcsupport/src/clock.c

diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am
index 6091f08261..66a8aa06da 100644
--- a/cpukit/libcsupport/Makefile.am
+++ b/cpukit/libcsupport/Makefile.am
@@ -66,6 +66,7 @@ SYSTEM_CALL_C_FILES = src/open.c src/close.c src/read.c 
src/write.c \
 src/fcntl.c src/fpathconf.c src/getdents.c src/fsync.c src/fdatasync.c \
 src/pipe.c src/dup.c src/dup2.c src/symlink.c src/readlink.c \
 src/chroot.c src/sync.c src/_rename_r.c src/statvfs.c src/utimes.c 
src/lchown.c
+SYSTEM_CALL_C_FILES += src/clock.c
 
 ## Until sys/uio.h is moved to libcsupport, we have to have networking
 ## enabled to compile these.  Hopefully this is a temporary situation.
diff --git a/cpukit/libcsupport/src/clock.c b/cpukit/libcsupport/src/clock.c
new file mode 100644
index 00..f976221a78
--- /dev/null
+++ b/cpukit/libcsupport/src/clock.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+
+#include 
+#include 
+
+RTEMS_STATIC_ASSERT( CLOCKS_PER_SEC == 100, clocks_per_sec );
+
+clock_t clock( void )
+{
+  struct timeval tv;
+
+  _Timecounter_Microuptime( &tv );
+
+  return (clock_t) (tv.tv_sec - 1) * CLOCKS_PER_SEC + tv.tv_usec;
+}
-- 
2.12.3

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel