#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2022 Oxide Computer Company
#

#
# Historical note: This header has never been part of ISO C. The
# visibility rules were always specific to versions of POSIX/XPG.
# Applications have assumed that these are visible even in a strict ISO
# C environment, which we honor because this header isn't part of the
# standard. See <sys/mman.h> for more details, but this is why you see
# the STDC group here for things that aren't standardized, as we want
# to make sure we don't regress that support.
#

#
# Types
#

#
# Values.
#
value	| PROT_READ	| int	| sys/mman.h	| +ALL
value	| PROT_WRITE	| int	| sys/mman.h	| +ALL
value	| PROT_EXEC	| int	| sys/mman.h	| +ALL
value	| PROT_NONE	| int	| sys/mman.h	| +ALL
value	| MAP_SHARED	| int	| sys/mman.h	| +ALL
value	| MAP_PRIVATE	| int	| sys/mman.h	| +ALL
value	| MAP_FILE	| int	| sys/mman.h	| +ALL
value	| MAP_FIXED	| int	| sys/mman.h	| +ALL
value	| MAP_NORESERVE	| int	| sys/mman.h	| +ALL
value	| MAP_ANON	| int	| sys/mman.h	| +ALL
value	| MAP_ALIGN	| int	| sys/mman.h	| +ALL
value	| MAP_TEXT	| int	| sys/mman.h	| +ALL
value	| MAP_INITDATA	| int	| sys/mman.h	| +ALL

value	| MCL_CURRENT	| int	| sys/mman.h	| STDC POSIX-1993+ SUSv2+
value	| MCL_FUTURE	| int	| sys/mman.h	| STDC POSIX-1993+ SUSv2+


value	| POSIX_MADV_NORMAL	| int	| sys/mman.h	| STDC SUSv3+
value	| POSIX_MADV_RANDOM	| int	| sys/mman.h	| STDC SUSv3+
value	| POSIX_MADV_SEQUENTIAL	| int	| sys/mman.h	| STDC SUSv3+
value	| POSIX_MADV_WILLNEED	| int	| sys/mman.h	| STDC SUSv3+
value	| POSIX_MADV_DONTNEED	| int	| sys/mman.h	| STDC SUSv3+

value	| MAP_FAILED	| void *	| sys/mman.h	| +ALL

#
# Defines
#

#
# Functions
#

#
# This first group of functions basically should always be visible.
#
func | mmap						|\
	void *						|\
	void *; size_t; int; int; int; off_t		|\
	sys/mman.h | +ALL

func | munmap						|\
	int						|\
	void *; size_t					|\
	sys/mman.h | +ALL

func | mprotect						|\
	int						|\
	void *; size_t; int				|\
	sys/mman.h | +ALL

func | msync						|\
	int						|\
	void *; size_t; int				|\
	sys/mman.h | +ALL


#
# This next group of functions were added in the realtime POSIX extensions, e.g.
# they should be in POSIX at POSIX-1993. However, they weren't part of XPG until
# XPG5, aka what we call SUSv2 in these tests.
#
func | mlock						|\
	int						|\
	void *; size_t					|\
	sys/mman.h | STDC POSIX-1993+ SUSv2+

func | munlock						|\
	int						|\
	void *; size_t					|\
	sys/mman.h | STDC POSIX-1993+ SUSv2+

func | mlockall						|\
	int						|\
	int						|\
	sys/mman.h | STDC POSIX-1993+ SUSv2+

func | munlockall					|\
	int						|\
	void						|\
	sys/mman.h | STDC POSIX-1993+ SUSv2+

func | shm_open						|\
	int						|\
	const char *; int; mode_t			|\
	sys/mman.h | STDC POSIX-1993+ SUSv2+

func | shm_unlink					|\
	int						|\
	const char *					|\
	sys/mman.h | STDC POSIX-1993+ SUSv2+

#
# Added in XPG6
#
func | posix_madvise					|\
	int						|\
	void *; size_t; int				|\
	sys/mman.h | STDC SUSv3+

#
# Our various extensions. No visibility expected in a standards environment. We
# do a handful of these with the assumption that as long as a few in the block
# are OK, the rest should be.
#
func | mincore						|\
	int						|\
	caddr_t; size_t; char *				|\
	sys/mman.h | -ALL STDC

func | memcntl						|\
	int						|\
	void *; size_t; int; void *; int; int		|\
	sys/mman.h | -ALL STDC

func | madvise						|\
	int						|\
	void *; size_t; int				|\
	sys/mman.h | -ALL STDC

func | getpagesizes					|\
	int						|\
	size_t *; int					|\
	sys/mman.h | -ALL STDC

func | getpagesizes2					|\
	int						|\
	size_t *; int					|\
	sys/mman.h | -ALL STDC