Tuesday, May 14, 2024
Homepage · c
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 763  / 2 Years ago, thu, april 21, 2022, 12:13:01

I found the problem with my fcntl implementation in js-ctypes. I was using the wrong constant values.





These guys are getting 1 2 3 for rdlck, wrlck, and unlck.




  • However when i run this C code to figure out the constnats on ubuntu its telling me they are 0, 1, and 2 :
    my constants on ubuntu


More From » c

 Answers
0

I'd say that those constant values are Linux specific, not Ubuntu specific.



In your C file, you're getting fcntl.h from /usr/include/fcntl.h which contains:





/* Get the definitions of O_*, F_*, FD_*: all the
numbers and flag bits for `open', `fcntl', et al. */
#include <bits/fcntl.h>


In /usr/include/<your_arch>/bits/fcntl.h you can see the following code:



/* Include generic Linux declarations.  */
#include <bits/fcntl-linux.h>


Finally this /usr/include/<your_arch>/bits/fcntl-linux.h file defines those values as follow:



#ifndef F_RDLCK
/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
# define F_RDLCK 0 /* Read lock. */
# define F_WRLCK 1 /* Write lock. */
# define F_UNLCK 2 /* Remove lock. */
#endif


To confirm that it's not Ubuntu specific, you can check the definitions in the libc source, they are the same.


[#23091] Thursday, April 21, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ovierman

Total Points: 445
Total Questions: 108
Total Answers: 111

Location: Libya
Member since Fri, Oct 30, 2020
4 Years ago
;