[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DECC |
Notice: | General DEC C discussions |
Moderator: | TLE::D_SMITH N TE |
|
Created: | Fri Nov 13 1992 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 2212 |
Total number of notes: | 11045 |
2134.0. "alignment fault reporting and gethostbyname OpenVMS AXP 7.1, DEC C 5.5-003" by COMICS::EDWARDSN (Dulce et decorum est pro PDP program) Tue Apr 01 1997 04:37
A customer has raised the following question about alignment fault reporting
for use with socket routines and specifically gethostbyname.
It would appear that gethostbyname is performing some nasties.
Alignment faults are reported when AFR is set to buffered mode, the customer would
like to use exception mode to trap the faults, but he isn't expecting this behaviour
from gethostbyname and thus is getting exceptions raised from code which he didn't
think he needed to check.
Is there something which can be done about the alignment faults or is it inherent
in the datastructures which are passed in sockets?
Can anyone assist?
Neil
The following is compiled using:
$ CC/DEB/NOOPT/PREF=ALL/DEF=AFRBUF
#include <time.h>
#include <socket.h>
#include <netdb.h>
#include <in.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#if defined(__vms) && defined(__alpha)
#include <afrdef.h>
#include <ssdef.h>
#include <starlet.h>
#define USER_BUFFER_ITEMS 10
#define GET_BUFFER_SIZE USER_BUFFER_ITEMS*AFR$K_USER_LENGTH
#define fault_pc afr$l_fault_pc_l
#define fault_va afr$l_fault_va_l
void note_unaligned_accesses()
{
static char save_buffer[512+64];
int sts;
#ifdef AFRBUF
sts = sys$start_align_fault_report( AFR$C_BUFFERED, save_buffer,
sizeof(save_buffer) );
#else
sts = sys$start_align_fault_report( AFR$C_EXCEPTION, NULL, 0 );
#endif
if ( sts != SS$_NORMAL )
{
printf( "Unable to start alignment fault reporting - status is %d\n", sts
);
exit( sts );
}
}
#ifdef AFRBUF
void print_unaligned_accesses()
{
char get_buffer[GET_BUFFER_SIZE];
struct afrdef *data_item;
int offset;
int status;
int return_size;
while (((status = sys$get_align_fault_data (get_buffer,
GET_BUFFER_SIZE,
&return_size)) > 0) &&
(return_size > 0)) {
/* got some data, print it */
offset = 0;
while (offset < return_size) {
data_item = (struct afrdef *)(&get_buffer[offset]);
printf ("Alignment fault at PC = %8.8X, VA = %8.8X\n",
data_item->fault_pc, data_item->fault_va);
offset += AFR$K_USER_LENGTH;
}
}
}
#else
#define print_unaligned_accesses()
#endif
#else
#define note_unaligned_accesses()
#define print_unaligned_accesses()
#endif
int main ()
{
struct hostent *ptemp;
note_unaligned_accesses();
ptemp = gethostbyname ("ncra") ;
if ( ptemp == NULL )
printf( "gethostbyname failed with status %d\n", errno );
print_unaligned_accesses();
return 1;
}
T.R | Title | User | Personal Name | Date | Lines |
---|
2134.1 | perhaps, not in the gethostbyname() routine itself | TAVENG::BORIS | Boris Gubenko, ISE | Tue Apr 01 1997 06:35 | 8 |
|
Currently I have no Alpha to check, but from the code it seems, that the
alignment fault is not in the DEC C RTL gethostbyname() routine itself.
gethostbyname() is no more than a wrapper to the UCX$GETHOSTBYNAME() which
is brought into memory via the call to LIB$FIND_IMAGE_SYMBOL.
Boris
|