Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

gethostsex(3)

swapsex(3)  —  RISC

Name

swap_word, swap_half, swap_filehdr, swap_aouthdr, swap_scnhdr, swap_hdr, swap_fd, swap_fi, swap_sym, swap_ext, swap_pd, swap_dn, swap_opt, swap_aux, swap_reloc, swap_ranlib − swap the sex of the specified structure

Syntax

#include <sex.h>
#include <filehdr.h>
#include <aouthdr.h>
#include <scnhdr.h>
#include <sym.h>
#include <symconst.h>
#include <cmplrs/stsupport.h>
#include <reloc.h>
#include <ar.h>

long swap_word( word )
long word;

short swap_half( half )
short half;

void swap_filehdr( pfilehdr, destsex )
FILHDR *pfilehdr;
long destsex;

void swap_aouthdr( paouthdr, destsex )
AOUTHDR *paouthdr;
long destsex;

void swap_scnhdr( pscnhdr, destsex )
SCNHDR *pscnhdr;
long destsex;

void swap_hdr( phdr, destsex )
pHDRR phdr;
long destsex;

void swap_fd( pfd, count, destsex )
pFDR pfd;
long count;
long destsex;

void swap_fi( pfi, count, destsex )
pFIT pfi;
long count;
long destsex;

void swap_sym( psym, count, destsex )
pSYMR psym;
long count;
long destsex;

void swap_ext( pext, count, destsex )
pEXTR pext;
long count;
long destsex;

void swap_pd( ppd, count, destsex )
pPDR ppd;
long count;
long destsex;

void swap_dn( pdn, count, destsex )
pRNDXR pdn;
long count;
long destsex;

void swap_opt( popt, count, destsex )
pOPTR popt;
long count;
long destsex;

void swap_aux( paux, type, destsex )
pAUXU paux;
long type;
long destsex;

void swap_reloc( preloc, count, destsex )
struct reloc *preloc;
long count;
long destsex;

void swap_ranlib( pranlib, count, destsex )
struct ranlib *pranlib;
long count;
long destsex;

Description

All swapsex routines that swap headers take a pointer to a header structure to change the byte’s sex. The destsex argument lets the swapsex routines decide whether to swap bitfields before or after swapping the words in which they occur. If destsex equals the hostsex of the machine you are running on, the flip happens before the swap; otherwise, the flip happens after the swap.  Although not all routines swap structures containing bitfields, the destsex is required. 

The swap_aux routine takes a pointer to an aux entry and a type, which is a ST_AUX_* constant in cmplrs/stsupport.h.  The constant specifies the type of the aux entry to change the sex of. All other swapsex routines are passed a pointer to an array of structures and a count of structures to have the byte sex changed.  The routines swap_word and swap_half are macros declared in sex.h.  Only the include files that describe the structures being swapped have to be included. 

See Also

gethostsex(3)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026