delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/03/12/10:27:32

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Thu, 12 Mar 2009 16:26:59 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: IOCTL using <ddk/ntddser.h>
Message-ID: <20090312152659.GA2364@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <loom DOT 20090311T224103-693 AT post DOT gmane DOT org> <20090312083353 DOT GB14431 AT calimero DOT vinschen DOT de> <loom DOT 20090312T144108-992 AT post DOT gmane DOT org>
MIME-Version: 1.0
In-Reply-To: <loom.20090312T144108-992@post.gmane.org>
User-Agent: Mutt/1.5.19 (2009-02-20)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Mar 12 14:52, Bert wrote:
> Corinna Vinschen <corinna-cygwin <at> cygwin.com> writes:
> > On Mar 11 22:57, Bert wrote:
> > > I hope I'm doing something really dumb, any tips?
> > 
> > Yes.  You're mixing POSIX calls with Windows defines.  That's a no-no.
> > When you're in Rome, talk like the Romans do.
> > 
> > Corinna
> > 
> 
> Many thanks Corinna. If I understand you correctly, "talk like the Romans" means
> "just make everything pure POSIX calls", right?  

Right.

> Secondly, if that's the case, what would the purpose of the Windows defines be?
> (Apart from confusing simple folks like me :)  Put another way, if I want to use
> those defines (i.e. flee Rome and settle in Babylon), what version of ioctl
> should I call and what libs should I link in?  

The native Windows headers provide you with a means to use native
Windows calls from a Cygwin application.

In your case, either talk POSIX with the com interface 
  
  open("/dev/com4");		// Btw. "/dev/ttyS3" is preferred
  ioctl(POSIX_IOCTL_CODE);
  close;

or talk Windows

  CreateFile("COM4:", ...);
  DeviceIoControl(WIN32_IOCTL_CODE);
  CloseHandle;

but don't mix them.  You will do yourself no good.  Given that the
Cygwin DLL has to keep track of state information, that should be clear.

If you open a file with a POSIX call, stick to POSIX for handling the
file until you close it.  The Cygwin DLL will do the translations.

If you need direct control for some reason, open the file with a
Windows call and stick to Windows calls until you close the file.

> Thirdly, and I'm probably pushing it now, if you have some favorite references
> to read on the above dichotomy? I'd appreciate the pointer. Or is it *pointer?

The dichotomy is mostely in your mind.  As soon as you realize that
Cygwin is a POSIX emulation layer on top of Windows, the above should
be quite clear.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019