diff mbox

Adding POSIX 1003.26 posix_devctl()

Message ID aa936e52-a14e-f13f-4b1b-e683071ef622@oarcorp.com
State New
Headers show

Commit Message

Joel Sherrill Dec. 1, 2016, 4:13 p.m. UTC
Hi

I am starting to add posix_devctl() support to RTEMS.
The POSIX 1003.26 standard defines only this single
method and the requirements boil down to the following:

The posix_devctl() method is defined by POSIX 1003.26-2003. Aside
from the single method, it adds the following requirements:

1. define _POSIX_26_VERSION to 200312L
2. add _SC_POSIX_26_VERSION in unistd.h. Return _POSIX_26_VERSION
3. application must define _POSIX_26_C_SOURCE to use posix_devctl().
4. posix_devctl() is prototyped in <devctl.h>
5. provide implementation of posix_devctl().:)

Based on requirements 1,2 and 4, I think the new .h
file and modifications to existing .h files need to be
done in newlib.

The implementation would go in RTEMS.

I have attached an initial cut at the patch. I think it
is close but it is untested.

Comments and thoughts appreciated.

Thanks.

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill@OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35806
Support Available                (256) 722-9985

Comments

Corinna Vinschen Dec. 5, 2016, 10:32 a.m. UTC | #1
Hi Joel,

On Dec  1 10:13, Joel Sherrill wrote:
> Hi

> 

> I am starting to add posix_devctl() support to RTEMS.

> The POSIX 1003.26 standard defines only this single

> method and the requirements boil down to the following:

> 

> The posix_devctl() method is defined by POSIX 1003.26-2003. Aside

> from the single method, it adds the following requirements:

> 

> 1. define _POSIX_26_VERSION to 200312L

> 2. add _SC_POSIX_26_VERSION in unistd.h. Return _POSIX_26_VERSION

> 3. application must define _POSIX_26_C_SOURCE to use posix_devctl().

> 4. posix_devctl() is prototyped in <devctl.h>

> 5. provide implementation of posix_devctl().:)

> 

> Based on requirements 1,2 and 4, I think the new .h

> file and modifications to existing .h files need to be

> done in newlib.

> 

> The implementation would go in RTEMS.

> 

> I have attached an initial cut at the patch. I think it

> is close but it is untested.

> 

> Comments and thoughts appreciated.


One nit.

> --- a/newlib/libc/include/sys/unistd.h

> +++ b/newlib/libc/include/sys/unistd.h

> @@ -459,6 +459,9 @@ int	_EXFUN(unlinkat, (int, const char *, int));

>  #define _SC_LEVEL4_CACHE_SIZE           137

>  #define _SC_LEVEL4_CACHE_ASSOC          138

>  #define _SC_LEVEL4_CACHE_LINESIZE       139

> +#ifdef _POSIX_26_VERSION

> +#define _SC_POSIX_26_VERSION            140

> +#endif


Do not #ifdef this definition.  Just define it.  It's either supported
by the implementation or not.  We shopuld avoid different _SC_ macros
for different targets.

With that, please commit.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
diff mbox

Patch

From e3479d5680525c9db3d8a4e214ff135a1f527080 Mon Sep 17 00:00:00 2001
From: Joel Sherrill <joel@rtems.org>
Date: Thu, 1 Dec 2016 09:46:32 -0600
Subject: [PATCH 2/2] Add <devctl.h> per POSIX 1003.26-2003

---
 newlib/libc/include/sys/features.h | 3 +++
 newlib/libc/include/sys/unistd.h   | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/newlib/libc/include/sys/features.h b/newlib/libc/include/sys/features.h
index 93635ba..a23158c 100644
--- a/newlib/libc/include/sys/features.h
+++ b/newlib/libc/include/sys/features.h
@@ -366,6 +366,9 @@  extern "C" {
 /* UNIX98 added some new pthread mutex attributes */
 #define _UNIX98_THREAD_MUTEX_ATTRIBUTES         1
 
+/* POSIX 1003.26-2003 defined device control method */
+#define _POSIX_26_VERSION			200312L
+
 #endif
 
 /* XMK loosely adheres to POSIX -- 1003.1 */
diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h
index 143147d..1e273ff 100644
--- a/newlib/libc/include/sys/unistd.h
+++ b/newlib/libc/include/sys/unistd.h
@@ -459,6 +459,9 @@  int	_EXFUN(unlinkat, (int, const char *, int));
 #define _SC_LEVEL4_CACHE_SIZE           137
 #define _SC_LEVEL4_CACHE_ASSOC          138
 #define _SC_LEVEL4_CACHE_LINESIZE       139
+#ifdef _POSIX_26_VERSION
+#define _SC_POSIX_26_VERSION            140
+#endif
 
 /*
  *  pathconf values per IEEE Std 1003.1, 2008 Edition
-- 
1.8.3.1