xref: /netbsd-src/crypto/external/bsd/openssh/dist/atomicio.h (revision aa36fcac57926c2ee7244eeb1b53bf604da30be9)
1*aa36fcacSchristos /*	$NetBSD: atomicio.h,v 1.8 2019/04/20 17:16:40 christos Exp $	*/
2*aa36fcacSchristos /* $OpenBSD: atomicio.h,v 1.12 2018/12/27 03:25:25 djm Exp $ */
3ca32bd8dSchristos 
4ca32bd8dSchristos /*
5ca32bd8dSchristos  * Copyright (c) 2006 Damien Miller.  All rights reserved.
6ca32bd8dSchristos  * Copyright (c) 1995,1999 Theo de Raadt.  All rights reserved.
7ca32bd8dSchristos  * All rights reserved.
8ca32bd8dSchristos  *
9ca32bd8dSchristos  * Redistribution and use in source and binary forms, with or without
10ca32bd8dSchristos  * modification, are permitted provided that the following conditions
11ca32bd8dSchristos  * are met:
12ca32bd8dSchristos  * 1. Redistributions of source code must retain the above copyright
13ca32bd8dSchristos  *    notice, this list of conditions and the following disclaimer.
14ca32bd8dSchristos  * 2. Redistributions in binary form must reproduce the above copyright
15ca32bd8dSchristos  *    notice, this list of conditions and the following disclaimer in the
16ca32bd8dSchristos  *    documentation and/or other materials provided with the distribution.
17ca32bd8dSchristos  *
18ca32bd8dSchristos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19ca32bd8dSchristos  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20ca32bd8dSchristos  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21ca32bd8dSchristos  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22ca32bd8dSchristos  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23ca32bd8dSchristos  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24ca32bd8dSchristos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25ca32bd8dSchristos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26ca32bd8dSchristos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27ca32bd8dSchristos  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28ca32bd8dSchristos  */
29ca32bd8dSchristos 
30ca32bd8dSchristos #ifndef _ATOMICIO_H
31ca32bd8dSchristos #define _ATOMICIO_H
32ca32bd8dSchristos 
33*aa36fcacSchristos struct iovec;
34*aa36fcacSchristos 
35ca32bd8dSchristos /*
36ca32bd8dSchristos  * Ensure all of data on socket comes through. f==read || f==vwrite
37ca32bd8dSchristos  */
38185c8f97Schristos size_t
39185c8f97Schristos atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
40185c8f97Schristos     int (*cb)(void *, size_t), void *);
41ca32bd8dSchristos size_t	atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t);
42ca32bd8dSchristos 
43ca32bd8dSchristos #define vwrite (ssize_t (*)(int, void *, size_t))write
44ca32bd8dSchristos 
45ca32bd8dSchristos /*
46ca32bd8dSchristos  * ensure all of data on socket comes through. f==readv || f==writev
47ca32bd8dSchristos  */
48185c8f97Schristos size_t
49185c8f97Schristos atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd,
50185c8f97Schristos     const struct iovec *_iov, int iovcnt, int (*cb)(void *, size_t), void *);
51ca32bd8dSchristos size_t	atomiciov(ssize_t (*)(int, const struct iovec *, int),
52ca32bd8dSchristos     int, const struct iovec *, int);
53ca32bd8dSchristos 
54ca32bd8dSchristos #endif /* _ATOMICIO_H */
55