Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2707: Implement most of POSIX stddef.h #2709

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/lib/posixlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ C Header Scala Native Module
`spawn.h`_ N/A
`stdarg.h`_ N/A
`stdbool.h`_ N/A
`stddef.h`_ N/A
`stddef.h`_ scala.scalanative.posix.stddef_
`stdint.h`_ N/A
`stdio.h`_ N/A
`stdlib.h`_ scala.scalanative.posix.stdlib_
Expand Down Expand Up @@ -200,6 +200,7 @@ C Header Scala Native Module
.. _scala.scalanative.posix.regex: https://github.com/scala-native/scala-native/blob/main/posixlib/src/main/scala/scala/scalanative/posix/regex.scala
.. _scala.scalanative.posix.sched: https://github.com/scala-native/scala-native/blob/main/posixlib/src/main/scala/scala/scalanative/posix/sched.scala
.. _scala.scalanative.posix.signal: https://github.com/scala-native/scala-native/blob/main/posixlib/src/main/scala/scala/scalanative/posix/signal.scala
.. _scala.scalanative.posix.stddef: https://github.com/scala-native/scala-native/blob/main/posixlib/src/main/scala/scala/scalanative/posix/stddef.scala
.. _scala.scalanative.posix.stdlib: https://github.com/scala-native/scala-native/blob/main/posixlib/src/main/scala/scala/scalanative/posix/stdlib.scala
.. _scala.scalanative.posix.sys.resource: https://github.com/scala-native/scala-native/blob/main/posixlib/src/main/scala/scala/scalanative/posix/sys/resource.scala
.. _scala.scalanative.posix.sys.select: https://github.com/scala-native/scala-native/blob/main/posixlib/src/main/scala/scala/scalanative/posix/sys/select.scala
Expand Down
4 changes: 4 additions & 0 deletions posixlib/src/main/resources/scala-native/stddef.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include <stddef.h>

// Macros
void *scalanative_posix_null() { return NULL; }
20 changes: 20 additions & 0 deletions posixlib/src/main/scala/scala/scalanative/posix/stddef.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package scala.scalanative
package posix

import scala.scalanative.unsafe._
import scala.scalanative.posix.sys.types

@extern
object stddef {
type ptrdiff_t = CLong
type wchar_t = CInt
type size_t = types.size_t

// Macros

// Ptr[Byte] is Scala Native convention for C (void *).
@name("scalanative_posix_null")
def NULL: Ptr[Byte] = extern

// offsetof() is not implemented in Scala Native.
}