You are not logged in.

#1 2010-04-10 21:53:41

JazzplayerL9
Member
Registered: 2006-03-31
Posts: 109

GCC sys/io.h -> insw function for Solaris? [Solved]

Hey all,

I'm by no means anywhere near qualified to say I'm a programmer, but I am trying to get a bit of code written in C++ and originally on Linux ported over to Solaris.  There is one function left that I'm having trouble finding a replacement/alternative for, and that is the function "insw" from sys/io.h.  Solaris doesn't have the sys/io.h header and I've been all over the net trying to find a solution with no success.  Does anyone know how to help? 

Thanks!

Last edited by JazzplayerL9 (2010-04-10 23:29:54)

Offline

#2 2010-04-10 22:44:01

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 859
Website

Re: GCC sys/io.h -> insw function for Solaris? [Solved]

insw's actual definition is in sys/io.h, and looks like this:

static __inline void
insw (unsigned short int __port, void *addr, unsigned long int __count)
{
  __asm__ __volatile__ ("cld ; rep ; insw":"=D" (addr), "=c" (__count)
                        :"d" (__port), "0" (addr), "1" (__count));
}

This is designed to be inlined in C or else it will break, but in C++, dropping the `static' from the definition and sticking it in some header file will work.  Oh, and use `inline' instead of `__inline'.

EDIT:  This is x86/x86_64-specific.  It's more complicated on other architectures; have a look at the arch/<your arch> folder in the kernel source for other implementations.

Last edited by tavianator (2010-04-10 22:51:45)

Offline

#3 2010-04-10 23:29:08

JazzplayerL9
Member
Registered: 2006-03-31
Posts: 109

Re: GCC sys/io.h -> insw function for Solaris? [Solved]

Thanks for the help, that worked just fine.  Got the program to build, but running it gives me more errors I'll have to figure out.

Offline

Board footer

Powered by FluxBB