HP C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


modf

Decomposes a floating-point number.

Format

#include <math.h>

double modf (double x, double *iptr);

float modff (float x, float *iptr); (INTEGRITY SERVERS, ALPHA)

long double modfl (long double x, long double *iptr); (INTEGRITY SERVERS, ALPHA)


Arguments

x

An object of type double , float , or long double .

iptr

A pointer to an object of type double , float , or long double to match the type of x.

Description

The modf functions decompose their first argument x into a positive fractional part f and an integer part i, each of which has the same sign as x.

The functions return f and assign i to the object pointed to by the second argument (iptr).


Return Values

x The fractional part of the argument x.
NaN x is NaN; errno is set to EDOM and * iptr is set to NaN.
0 Underflow occurred; errno is set to ERANGE.

[w]move

Change the current cursor position on the specified window to the coordinates (y,x). The move function acts on the stdscr window.

Format

#include <curses.h>

int move (int y, int x);

int wmove (WINDOW *win, int y, int x);


Arguments

win

A pointer to the window.

y

A window coordinate.

x

A window coordinate.

Description

For more information, see the scrollok function in this section.

Return Values

OK Indicates success.
ERR Indicates that the function makes the screen scroll illegally.

mprotect

Modifies access protections of memory mapping. This function is reentrant.

Format

#include <mman.h>

int mprotect (void *addr, size_t len, int prot);


Arguments

addr

The address of the region that you want to modify.

len

The length, in bytes, of the region that you want to modify.

prot

Access permission, as defined in the <mman.h> header file. Specify either PROT_NONE, PROT_READ, or PROT_WRITE.

Description

The mprotect function modifies the access protection of a mapped file or shared memory region.

The addr and len arguments specify the address and length, in bytes, of the region that you want to modify. The len argument must be a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE) . If len is not a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE) , the length of the region is rounded up to the next multiple of the page size.

The prot argument specifies access permissions for the mapped region. Specify one of the following:
PROT_NONE No access
PROT_READ Read-only
PROT_WRITE Read/Write access

The mprotect function does not modify the access permission of any region that lies outside of the specified region, except that the effect on addresses between the end of the region, and the end of the page containing the end of the region, is unspecified.

If the mprotect function fails under a condition other than that specified by EINVAL, the access protection of some of the pages in the range [addr, addr + len] can change. Suppose the error occurs on some page at an addr2; mprotect can modify protections of all whole pages in the range [addr, addr2].

See also sysconf .


Return Values

0 Indicates success.
- 1 Indicates an error; errno is set to one of the following values:
  • EACCESS -- The prot argument specifies a protection that conflicts with the access permission set for the underlying file.
  • EINVAL -- The prot argument is invalid, or the addr argument is not a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE) .
  • EFAULT -- The range [ addr, addr + len] includes an invalid address.

mrand48

Generates uniformly distributed pseudorandom-number sequences. Returns 48-bit signed long integers.

Format

#include <stdlib.h>

long int mrand48 (void);


Description

The mrand48 function generates pseudorandom numbers using the linear congruential algorithm and 48-bit integer arithmetic.

It returns signed long integers uniformly distributed over the range of y values such that -231 <= y < 231 .

Before you call the mrand48 function, use either srand48 , seed48 , or lcong48 to initialize the random-number generator. You must initialize the mrand48 function prior to invoking it, because it stores the last 48-bit Xi generated into an internal buffer. (Although it is not recommended, constant default initializer values are supplied automatically if the drand48 , lrand48 , or mrand48 functions are called without first calling an initialization function.)

The function works by generating a sequence of 48-bit integer values, Xi, according to the linear congruential formula:


       Xn+1 = (aXn+c)mod m        n >= 0 

The argument m equals 248 , so 48-bit integer arithmetic is performed. Unless you invoke the lcong48 function, the multiplier value a and the addend value c are:


      a = 5DEECE66D16 = 2736731631558
      c = B16 = 138

The values returned by the mrand48 function is computed by first generating the next 48-bit Xi in the sequence. Then the appropriate bits, according to the type of returned data item, are copied from the high-order (most significant) bits of Xi and transformed into the returned value.

See also drand48 , lrand48 , lcong48 , seed48 , and srand48 .


Return Value

n Returns signed long integers uniformly distributed over the range -2 31 <= y < 2 31 .

msync

Synchronizes a mapped file.

Format

#include <mman.h>

int msync (void *addr, size_t len, int flags);


Arguments

addr

The address of the region that you want to synchronize.

len

The length, in bytes, of the region that you want to synchronize.

flags

One of the following symbolic constants defined in the <mman.h> header file:
MS_SYNC Synchronous cache flush
MS_ASYNC Asynchronous cache flush
MS_INVALIDATE Invalidate cashed pages

Description

The msync function controls the caching operations of a mapped file region. Use msync to:

The addr and len arguments specify the region to be synchronized. The len argument must be a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE) ; otherwise, the length of the region is rounded up to the next multiple of the page size.

If the flags argument is set to:
flags Argument Then the msync Function...
MS_SYNC Does not return until the system completes all I/O operations.
MS_ASYNC Returns after the system schedules all I/O operations.
MS_INVALIDATE Invalidates all cached copies of the pages. The operating system must obtain new copies of the pages from the file system the next time the application references them.

After a successful call to the msync function with the flags argument set to:

See also read , write , and sysconf .


Return Values

0 Indicates success.
- 1 Indicates an error; errno is set to one of the following values:
  • EIO -- An I/O error occurred while reading from or writing to the file system.
  • ENOMEM -- The range specified by [ addr, addr + len] is invalid for a process's address space, or the range specifies one or more unmapped pages.
  • EINVAL -- The addr argument is not a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE) .
  • EFAULT -- The range [ addr, addr + len] includes an invalid address.

munmap

Unmaps a mapped region. This function is reentrant.

Format

#include <mman.h>

int munmap (void *addr, size_t len);


Arguments

addr

The address of the region that you want to unmap.

len

The length, in bytes, of that region the you want to unmap.

Description

The munmap function unmaps a mapped file or shared memory region.

The addr and len arguments specify the address and length, in bytes, respectively, of the region to be unmapped.

The len argument must be a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE) ; otherwise, the length of the region is rounded up to the next multiple of the page size.

The result of using an address that lies in an unmapped region and not in any subsequently mapped region is undefined.

See also sysconf .


Return Values

0 Indicates success.
- 1 Indicates an error; errno is set to one of the following values:
  • ENIVAL -- The addr argument is not a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE) .
  • EFAULT -- The range [ addr, addr + len] includes an invalid address.

mv[w]addch

Move the cursor to coordinates (y,x) and add a character to the specified window.

Format

#include <curses.h>

int mvaddch (int y, int x, char ch);

int mvwaddch (WINDOW *win, int y, int x, char ch);


Arguments

win

A pointer to the window.

y

A window coordinate.

x

A window coordinate.

ch

If this argument is a new-line character (\n), the mvaddch and mvwaddch functions clear the line to the end, and move the cursor to the next line at the same x coordinate. A carriage return (\r) moves the cursor to the beginning of the specified line. A tab (\t) moves the cursor to the next tabstop within the window.

Description

This routine performs the same function as mvwaddch , but on the stdscr window.

When mvwaddch is used on a subwindow, it writes the character onto the underlying window as well.


Return Values

OK Indicates success.
ERR Indicates that writing the character would cause the screen to scroll illegally. For more information, see the scrollok function.

mv[w]addstr

Move the cursor to coordinates (y,x) and add the specified string, to which str points, to the specified window.

Format

#include <curses.h>

int mvaddstr (int y, int x, char *str);

int mvwaddstr (WINDOW *win, int y, int x, char *str);


Arguments

win

A pointer to the window.

y

A window coordinate.

x

A window coordinate.

str

A pointer to the character string.

Description

This routine performs the same function as mvwaddstr , but on the stdscr window.

When mvwaddstr is used on a subwindow, the string is written onto the underlying window as well.


Return Values

OK Indicates success.
ERR Indicates that the function causes the screen to scroll illegally, but it places as much of the string onto the window as possible. For more information, see the scrollok function.

mvcur

Moves the terminal's cursor from (lasty,lastx) to (newy,newx).

Format

#include <curses.h>

int mvcur (int lasty, int lastx, int newy, int newx);


Arguments

lasty

The cursor position.

lastx

The cursor position.

newy

The resulting cursor position.

newx

The resulting cursor position.

Description

In HP C for OpenVMS Systems, mvcur and move perform the same function.

See also move .


Return Values

OK Indicates success.
ERR Indicates that moving the window placed part or all of the window off the edge of the terminal screen. The terminal screen remains unaltered.

mv[w]delch

Move the cursor to coordinates (y,x) and delete the character on the specified window. The mvdelch function acts on the stdscr window.

Format

#include <curses.h>

int mvdelch (int y, int x);

int mvwdelch (WINDOW *win, int y, int x);


Arguments

win

A pointer to the window.

y

A window coordinate.

x

A window coordinate.

Description

Each of the following characters on the same line shifts to the left, and the last character becomes blank.

Return Values

OK Indicates success.
ERR Indicates that deleting the character would cause the screen to scroll illegally. For more information, see the scrollok function.

mv[w]getch

Move the cursor to coordinates (y,x), get a character from the terminal screen, and echo it on the specified window. The mvgetch function acts on the stdscr window.

Format

#include <curses.h>

int mvgetch (int y, int x);

int mvwgetch (WINDOW *win, int y, int x);


Arguments

win

A pointer to the window.

y

A window coordinate.

x

A window coordinate.

Description

The mvgetch and mvwgetch functions refresh the specified window before fetching the character.

Return Values

x The returned character.
ERR Indicates that the function causes the screen to scroll illegally. For more information, see the scrollok function in this section.

mv[w]getstr

Move the cursor to coordinates (y,x), get a string from the terminal screen, store it in the variable str (which must be large enough to contain the string), and echo it on the specified window. The mvgetstr function acts on the stdscr window.

Format

#include <curses.h>

int mvgetstr (int y, int x, char *str);

int mvwgetstr (WINDOW *win, int y, int x, char *str);


Arguments

win

A pointer to the window.

y

A window coordinate.

x

A window coordinate.

str

The string that is displayed.

Description

The mvgetstr and mvwgetstr functions strip the new-line terminator (\n) from the string.

Return Values

OK Indicates success.
ERR Indicates that the function causes the screen to scroll illegally.

mv[w]inch

Move the cursor to coordinates (y,x) and return the character on the specified window without making changes to the window. The mvinch function acts on the stdscr window.

Format

#include <curses.h>

int mvinch (int y, int x);

int mvwinch (WINDOW *win, int y, int x);


Arguments

win

A pointer to the window.

y

A window coordinate.

x

A window coordinate.

Return Values

x The returned character.
ERR Indicates an input error.


Previous Next Contents Index