/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "streams_mmap.h"
#include "streams_common.h"
/*
* Single-byte character memory map-based streams implementation
*/
static int
{
char *nl;
if (stream_is_primed(str))
return (PRIME_SUCCEEDED);
if (str->s_buffer_size == 0) {
return (PRIME_FAILED_EMPTY_FILE);
}
NULL) {
} else {
}
return (PRIME_SUCCEEDED);
}
/*
* stream_mmap_fetch() sets the fields of str->s_current to delimit the next
* line of the field.
*/
static ssize_t
{
char *next_nl;
/*
* adding one for newline
*/
if (next_nl)
else {
}
/*
* adding one for newline
*/
return (NEXT_LINE_COMPLETE);
}
static int
{
return (1);
return (0);
}
static int
{
return (1);
}
return (0);
}
static int
{
return (0);
return (1);
str->s_buffer_size = 0;
return (1);
}
static int
{
int retval = 0;
return (1);
/*
* If the file's size is known to be zero, then we are at EOS; the
* remaining checks are only sensible if we successfully primed this
* stream. The additional character is for the optional newline.
*/
if (str->s_filesize == 0 ||
str->s_buffer_size)) {
retval = 1;
}
return (retval);
}
/*
* In certain cases, we know that we will never need the data on a page again
* for the duration of the sort. (These cases are associated with merges
* involving temporary files.) We can thus release all pages previous to the
* page containing the current line, using the MADV_DONTNEED flag to
* madvise(3C). This additional memory management improves our chances of
* avoiding a paging situation, by evicting pages we know are of no use.
*/
static void
{
if (release == 0)
return;
}
NULL,
NULL,
NULL,
NULL,
};