summaryrefslogtreecommitdiffstats
path: root/src/evalvars.c
AgeCommit message (Expand)Author
2024-04-24patch 9.1.0369: Vim9: problem when importing autoloaded scriptsv9.1.0369Ernie Rael
2024-04-21patch 9.1.0360: Vim9: does not handle autoloaded variables wellv9.1.0360Ernie Rael
2024-04-15patch 9.1.0335: String interpolation fails for List typev9.1.0335Yegappan Lakshmanan
2024-04-13patch 9.1.0313: Crash when using heredoc with comment in command blockv9.1.0313zeertzjq
2024-04-12patch 9.1.0312: heredocs are not supported for :commandsv9.1.0312Yegappan Lakshmanan
2024-03-28patch 9.1.0219: Vim9: No enum supportv9.1.0219Yegappan Lakshmanan
2024-03-09patch 9.1.0160: Vim9: Add support for using a class type of itself in an obje...v9.1.0160Yegappan Lakshmanan
2024-02-12patch 9.1.0102: settabvar() may change the last accessed tabpagev9.1.0102zeertzjq
2024-02-06patch 9.1.0080: unexpected error for modifying final list using +=v9.1.0080Yegappan Lakshmanan
2024-01-16patch 9.1.0034: Window scrolls unexpectedly when 'scrollbind' is setv9.1.0034Christian Brabandt
2024-01-04patch 9.1.0006: is*() and to*() function may be unsafev9.1.0006Keith Thompson
2023-12-21patch 9.0.2184: Vim9: inconsistent :type/:class messagesv9.0.2184Ernie Rael
2023-12-19patch 9.0.2180: POSIX function name in exarg causes issuesv9.0.2180Zoltan Arpadffy
2023-12-18patch 9.0.2174: Vim9: segfault when assigning to typev9.0.2174Ernie Rael
2023-12-11patch 9.0.2156: Vim9: can use typealias in assignmentv9.0.2156Ernie Rael
2023-10-28patch 9.0.2078: several problems with type aliasesv9.0.2078Yegappan Lakshmanan
2023-10-27patch 9.0.2076: Vim9: No support for type aliasesv9.0.2076Yegappan Lakshmanan
2023-10-05patch 9.0.1986: Vim9: accepting type-annotationsv9.0.1986Yegappan Lakshmanan
2023-10-04patch 9.0.1982: vim9: clean up from v9.0.1955v9.0.1982Ernie Rael
2023-09-29patch 9.0.1955: Vim9: lockvar issues with objects/classesv9.0.1955Ernie Rael
2023-09-24patch 9.0.1933: Can change the type of a v: variable using if_luav9.0.1933zeertzjq
2023-08-20patch 9.0.1776: No support for stable Python 3 ABIv9.0.1776Yee Cheng Chin
2023-08-19patch 9.0.1741: No type checking in interfacesv9.0.1741LemonBoy
2023-06-14patch 9.0.1631: passing wrong variable type to option gives multiple errorsv9.0.1631zeertzjq
2023-06-05patch 9.0.1611: v:maxcol can be changed in a :for loopv9.0.1611Bram Moolenaar
2023-05-24patch 9.0.1576: users may not know what to do with an internal errorv9.0.1576Bram Moolenaar
2023-04-12patch 9.0.1447: condition is always truev9.0.1447zeertzjq
2023-03-07patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected filev9.0.1390Yegappan Lakshmanan
2023-02-01patch 9.0.1271: using sizeof() and subtract array size is trickyv9.0.1271zeertzjq
2023-01-30patch 9.0.1266: error for space before ": type" is inconsistentv9.0.1266Bram Moolenaar
2023-01-12patch 9.0.1188: return value of type() for class and object unclearv9.0.1188Bram Moolenaar
2023-01-12patch 9.0.1186: imported class does not work when used twice in a linev9.0.1186Bram Moolenaar
2023-01-12patch 9.0.1185: using class from imported script not testedv9.0.1185Bram Moolenaar
2023-01-06patch 9.0.1152: class "implements" argument not implementedv9.0.1152Bram Moolenaar
2023-01-03patch 9.0.1137: some conditions are always falsev9.0.1137zeertzjq
2023-01-02patch 9.0.1133: error message names do not match the itemsv9.0.1133Bram Moolenaar
2023-01-02patch 9.0.1132: code is indented more than neededv9.0.1132Yegappan Lakshmanan
2022-12-08patch 9.0.1031: Vim9 class is not implemented yetv9.0.1031Bram Moolenaar
2022-12-02patch 9.0.0990: callback name argument is changed by setqflist()v9.0.0990Bram Moolenaar
2022-11-28patch 9.0.0965: using one window for executing autocommands is insufficientv9.0.0965Bram Moolenaar
2022-11-25patch 9.0.0949: crash when unletting a variable while listing variablesv9.0.0949Bram Moolenaar
2022-11-16patch 9.0.0890: no test for what patch 9.0.0827 fixesv9.0.0890Bram Moolenaar
2022-10-13patch 9.0.0744: in script in autoload dir exported variable is not foundv9.0.0744Bram Moolenaar
2022-10-12patch 9.0.0732: no check for white space before and after "=<<"v9.0.0732Bram Moolenaar
2022-10-01patch 9.0.0634: evaluating "expr" options has more overhead than neededv9.0.0634Bram Moolenaar
2022-09-21patch 9.0.0535: closure gets wrong value in for loop with two loop variablesv9.0.0535Bram Moolenaar
2022-09-14patch 9.0.0460: loop variable can't be foundv9.0.0460Bram Moolenaar
2022-09-11patch 9.0.0444: trying to declare g:variable gives confusing errorv9.0.0444Bram Moolenaar
2022-09-06patch 9.0.0398: members of funccall_T are inconsistently namedv9.0.0398Bram Moolenaar
2022-09-03patch 9.0.0364: clang static analyzer gives warningsv9.0.0364Yegappan Lakshmanan
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128
/*
 *  linux/fs/pipe.c
 *
 *  Copyright (C) 1991, 1992, 1999  Linus Torvalds
 */

#include <linux/mm.h>
#include <linux/file.h>
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/log2.h>
#include <linux/mount.h>
#include <linux/magic.h>
#include <linux/pipe_fs_i.h>
#include <linux/uio.h>
#include <linux/highmem.h>
#include <linux/pagemap.h>
#include <linux/audit.h>
#include <linux/syscalls.h>
#include <linux/fcntl.h>
#include <linux/aio.h>

#include <asm/uaccess.h>
#include <asm/ioctls.h>

#include "internal.h"

/*
 * The max size that a non-root user is allowed to grow the pipe. Can
 * be set by root in /proc/sys/fs/pipe-max-size
 */
unsigned int pipe_max_size = 1048576;

/*
 * Minimum pipe size, as required by POSIX
 */
unsigned int pipe_min_size = PAGE_SIZE;

/*
 * We use a start+len construction, which provides full use of the 
 * allocated memory.
 * -- Florian Coosmann (FGC)
 * 
 * Reads with count = 0 should always return 0.
 * -- Julian Bradfield 1999-06-07.
 *
 * FIFOs and Pipes now generate SIGIO for both readers and writers.
 * -- Jeremy Elson <jelson@circlemud.org> 2001-08-16
 *
 * pipe_read & write cleanup
 * -- Manfred Spraul <manfred@colorfullife.com> 2002-05-09
 */

static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
{
	if (pipe->files)
		mutex_lock_nested(&pipe->mutex, subclass);
}

void pipe_lock(struct pipe_inode_info *pipe)
{
	/*
	 * pipe_lock() nests non-pipe inode locks (for writing to a file)
	 */
	pipe_lock_nested(pipe, I_MUTEX_PARENT);
}
EXPORT_SYMBOL(pipe_lock);

void pipe_unlock(struct pipe_inode_info *pipe)
{
	if (pipe->files)
		mutex_unlock(&pipe->mutex);
}
EXPORT_SYMBOL(pipe_unlock);

static inline void __pipe_lock(struct pipe_inode_info *pipe)
{
	mutex_lock_nested(&pipe->mutex, I_MUTEX_PARENT);
}

static inline void __pipe_unlock(struct pipe_inode_info *pipe)
{
	mutex_unlock(&pipe->mutex);
}

void pipe_double_lock(struct pipe_inode_info *pipe1,
		      struct pipe_inode_info *pipe2)
{
	BUG_ON(pipe1 == pipe2);

	if (pipe1 < pipe2) {
		pipe_lock_nested(pipe1, I_MUTEX_PARENT);
		pipe_lock_nested(pipe2, I_MUTEX_CHILD);
	} else {
		pipe_lock_nested(pipe2, I_MUTEX_PARENT);
		pipe_lock_nested(pipe1, I_MUTEX_CHILD);
	}
}

/* Drop the inode semaphore and wait for a pipe event, atomically */
void pipe_wait(struct pipe_inode_info *pipe)
{
	DEFINE_WAIT(wait);

	/*
	 * Pipes are system-local resources, so sleeping on them
	 * is considered a noninteractive wait:
	 */
	prepare_to_wait(&pipe->wait, &wait, TASK_INTERRUPTIBLE);
	pipe_unlock(pipe);
	schedule();
	finish_wait(&pipe->wait, &wait);
	pipe_lock(pipe);
}

static void anon_pipe_buf_release(struct pipe_inode_info *pipe,
				  struct pipe_buffer *buf)
{
	struct page *page = buf->page;

	/*
	 * If nobody else uses this page, and we don't already have a
	 * temporary page, let's keep track of it as a one-deep
	 * allocation cache. (Otherwise just release our reference to it)
	 */
	if (page_count(page) == 1 && !pipe->tmp_page)
		pipe->tmp_page = page;
	else
		page_cache_release(page);
}

/**
 * generic_pipe_buf_steal - attempt to take ownership of a &pipe_buffer
 * @pipe:	the pipe that the buffer belongs to
 * @buf:	the buffer to attempt to steal
 *
 * Description:
 *	This function attempts to steal the &struct page attached to
 *	@buf. If successful, this function returns 0 and returns with
 *	the page locked. The caller may then reuse the page for whatever
 *	he wishes; the typical use is insertion into a different file
 *	page cache.
 */
int generic_pipe_buf_steal(struct pipe_inode_info *pipe,
			   struct pipe_buffer *buf)
{
	struct page *page = buf->page;

	/*
	 * A reference of one is golden, that means that the owner of this
	 * page is the only one holding a reference to it. lock the page
	 * and return OK.
	 */
	if (page_count(page) == 1) {
		lock_page(page);
		return 0;
	}

	return 1;
}
EXPORT_SYMBOL(generic_pipe_buf_steal);

/**
 * generic_pipe_buf_get - get a reference to a &struct pipe_buffer
 * @pipe:	the pipe that the buffer belongs to
 * @buf:	the buffer to get a reference to
 *
 * Description:
 *	This function grabs an extra reference to @buf. It's used in
 *	in the tee() system call, when we duplicate the buffers in one
 *	pipe into another.
 */
void generic_pipe_buf_get(struct pipe_inode_info *pipe, struc